Linux 下MySQL数据库配置远程访问

时间:2022-09-18 22:27:15

1. mysql -u root -p

第一次直接回车跳过密码

 

2. use mysql;

 

3.执行授权命令

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;

 

 

MySQL相关问题

10061 :MySQL服务未启动

10060 :3306端口系统防火墙未开放

 

启动MySQL服务

/etc/init.d/mysqld start

 

断电后启动失败问题解决方案

cd /var/lib/mysql/

rm -rf mysql.sock

/etc/init.d/mysqld restart

 

 

修改root用户密码

set password for root@localhost = password('123456'); 

修改root用户密码为123456

 

设置字符集为UTF-8

set character_set_client = utf8;
set character_set_connection = utf8;
set character_set_database = utf8;
set character_set_results = utf8;
set character_set_server = utf8;

show variables like '%character%';