[mysqld] #设置服务端 # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove the leading "# " to disable binary logging # Binary logging captures changes between backups and is enabled by # default. It's default setting is log_bin=binlog # disable_log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M # # Remove leading # to revert to previous value for default_authentication_plugin, # this will increase compatibility with older clients. For background, see: # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin # default-authentication-plugin=mysql_native_password #设置端口号,默认3306 #port=3306 # 设置mysql的安装目录 #basedir=/usr/local/mysql # 设置mysql数据库的数据的存放目录 datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock
#获取初始密码,这样我们就可以登录了 grep password /var/log/mysqld.log #先登录mysql客户端,输入密码不会显示 mysql -uroot -p #设置密码 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; #重新加载权限表 flush privileges; #开启远程登录的密码 create user 'root'@'%' identified with mysql_native_password by '123456'; #重新加载权限表 flush privileges; #赋权命令 以下命令二选一 # all privileges 当前用户所有权限 # *.*赋予所有权限 # with grant option允许级联赋权 #1.任何主机访问都可以连接 '%' grant all privileges on *.* to 'root'@'%' with grant option; #2.指定主机访问可连接 grant all privileges on *.* to 'root'@'192.168.1.102' with grant option; #重新加载权限表 flush privileges;