- mysql8修改登陆host: update user set host='%' where user='root';
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '设置的密码';
Centos6安装二进制MySQL5.7
由于centos6的yum源停更,索性安装个二进制的mysql5.7
- 1.下载mysql-5.7.42-linux-glibc2.12-x86_64.tar.gz
2. 创建一个mysql用户和组
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
3. cd /usr/local
tar zxvf /path/to/mysql-5.7.42-linux-glibc2.12-x86_64.tar.gz
ln -s full-path-to-mysql-VERSION-OS mysql
export PATH=$PATH:/usr/local/mysql/bin
tips: bin/mysqld --initialize --user=mysql #会产生随机密码
bin/mysqld --initialize-insecure --user=mysql #不会产生密码,也就是空密码.
4. cd /usr/local/mysql/etc
[root@iZ2ze0qgk4uiaovdokqk9uZ etc]# cat my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3307
user=mysql
其他参数复制的原rds上的参数.
5.进行初始化 bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf
--initialize-insecure --user=mysql
追加:如果后期追加了其他参数,数据库启动不了,可能还需要进行初始化;感觉还是yum安装的好.
6.启动mysql: mysqld_safe &
7.连接后,使用ALTER USER语句来分配新的root密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';
或使用:update user set authentication_string=PASSWORD("hahaha") where user='root';
8.mysql> use mysql;
update user set host = '%' where user = 'root';
9.查看用户
select user,host from mysql.user;
总结:之前程序用的是rds-mysql,从阿里云上迁自建数据库,最好把原来的参数一块迁过来,使用数据同步,虽然慢,但是能保证源表和目标之间数据相同,否则程序就是不认自建的Mysql.
标签:--,root,Mysql,user,mysql,local,usr From: https://www.cnblogs.com/DuWenjie/p/17370010.html