mysql配置详解及root密码重置和远程登录

回复 收藏
my.cnf核心配置
调优参考:http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=5758&highlight=mysql%B5%F7%D3%C5
[mysqld]
port            = 3306                                                         #mysql端口
socket          = /tmp/mysql.sock                                    #监听的saoket
skip-locking                                                                   #过滤掉lock
key_buffer_size = 256M                                                 #buffer内存的配置参数,索引缓冲区
(1G以下内存设定128M;2G/256M; 4G/384M;8G/1024M;16G/2048M)
max_allowed_packet = 1M                                            #外部管理工具最大的包
table_open_cache = 256                                                #所有的线程,打开表的数量
sort_buffer_size = 1M                                                    #排序的缓冲区大小
read_buffer_size = 1M                                                   #读数据的时候的缓冲区
read_rnd_buffer_size = 4M                                            #随机读的缓冲区
myisam_sort_buffer_size = 64M                                    #myisam配置的缓冲区
thread_cache_size = 8                                                    #缓存可重用的线程数
query_cache_size= 16M                                                 #查询的缓存大小
# Try number of CPU's*2 for thread_concurrency         
thread_concurrency = 8                                                 #最大并发线程数
interactive_timeout = 8
wait_timeout = 8
慢查询:
long_query_time = 1
log_slow_queries= /data/mysql/slow.log

密码设置及重置
设置密码:mysqladmin -uroot password 'www123cuserom'
初始化密码:
编辑:vim /etc/my.cnf
添加一行:skip-grant
重启mysql service mysqld restart
然后登陆mysql使用空密码:mysql
mysql>use mysql
mysql>update user set password=password('www.123.com')  whare user='root';
mysql>select * from user where user='root'\G;
然后删除/etc/my.cnf下的skip-grant

登陆远程mysql服务器
授权IP登陆:grant all on *.*  to  'root'@'192.168.0.111' identified by '123aaa';
生效:use mysql
查看授权结果:select * from user where host='192.168.0.111'\G;
关闭防火墙或者开启3306端口
远程连接方式:
mysql -uroot  -h192.168.238.128 -P3306 -pwww.123.ccom



2016-07-13 10:32 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: