mysql5.6 linux 安装设置密码和远程登录

本文介绍了如何通过编辑my.cnf文件启用MySQL的skip-grant-tables选项来跳过登录验证,然后设置新的root用户密码。接着,文章详细说明了如何设置允许root用户从任何主机远程登录,并在完成后恢复正常的权限系统。最后,提醒读者在完成设置后要删除或注释掉skip-grant-tables选项,并重启MySQL服务以应用更改。
摘要由CSDN通过智能技术生成

mysql 设置跳过登陆验证:

vim /etc/my.cnf文件;
在[mysqld]后添加skip-grant-tables(登录时跳过权限检查)

[mysqld]
skip-grant-tables
port        = 3306
socket        = /tmp/mysql.sock
datadir = /www/server/data
default_storage_engine = InnoDB
performance_schema_max_table_instances = 400
table_definition_cache = 400
skip-external-locking
key_buffer_size = 64M
max_allowed_packet = 100G
table_open_cache = 256
sort_buffer_size = 1M
net_buffer_length = 4K

重启systemctl restart mysqld

mysql 设置密码:

登录mysql,输入mysql -h localhost -u root -P 3306 -p;直接回车(Enter)


use mysql;

set password for 'root'@'localhost'=password('1234!@#$qwerQWER');

如果报:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
输入:
flush privileges;
再输入:
set password for 'root'@'localhost'=password('1234!@#$qwerQWER');

flush privileges;

mysql 设置远程登录:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY '1234!@#$qwerQWER' WITH GRANT OPTION;

flush privileges;

再把my.ini的skip-grant-tables删除或者注释掉

重启MySQL:sudo systemctl restart mysqld
再次连接,成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值