[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 leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /tmp/mysql.sock log-error = /usr/local/mysql/data/error.log pid-file = /usr/local/mysql/data/mysql.pid tmpdir = /tmp port = 3306 #lower_case_table_names = 1 # server_id = ..... # socket = ..... #lower_case_table_names = 1 max_allowed_packet=32M default-authentication-plugin = mysql_native_password #lower_case_file_system = on #lower_case_table_names = 1 log_bin_trust_function_creators = ON # 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 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
开机自启
进入/usr/local/mysql/support-files进行设置
1 2 3
cd support-files/ cp mysql.server /etc/init.d/mysql chmod +x /etc/init.d/mysql
注册服务
1 2
chkconfig --add mysql chkconfig --list mysql # 查看是否成功
配置路径与环境变量
1 2 3 4 5 6 7 8 9
vim /etc/ld.so.conf # 添加如下内容并保存退出 /usr/local/mysql/lib
# 配置环境变量 vim /etc/profile export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib # 保存退出 source /etc/profile
修改密码
登录mysql并修改初始随机密码
mysql -u root -p alter user ‘root‘@’localhost’ identified by ‘12345’; flush privileges;
报错解决
出现如下报错:
Can ‘t connect to local MySQL server through socket ‘/tmp/mysql.sock 解决办法:重启服务 systemctl restart mysql