Linux下安装Mysql问题总结
---恢复内容开始---
1-检查系统自带的Mysql,并卸载自带版本及(系统CentOS6.5)
1--检查系统是否自带Mysql------[root@localhost Desktop] # yum list installed | grep mysql
2--删除系统自带的mysql及其依赖包
1--[root@localhost Desktop] yum -y remove mysql-libs.x86_64
2--删除完成后,重新执行yum list installed | grep mysql则不会有任何信息
2-使用yum安装,部署版本:CentOS6.5 + Mysql5.7
1--执行命令:wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
2--验证下看是否下载成功:ls /etc/software 可以看到rpm包
3--执行命令:yum localinstall mysql-community-release-el6-5.noarch.rpm
4--验证本地yum是否安装成功---------执行:yum repolist all | grep mysql
5--升级版本到5.7
1--编辑配置(文件,简单,不容易出错):vi /etc/yum.repos.d/mysql-community.repo
2--把5.6的enable=0,把5.7的enable=1,按insert编辑,编辑之后,按Esc退出编辑,再输入 :wq 保存并退出
3--再执行: yum repolist all | grep mysql 进行确认-----成功确认 :mysql57-community-dmr MySQL 5.7 Community Server Deve enabled: 237
4--执行下面命令安装 mysql server 和 mysql devel
1---yum install mysql-server
2--yum install mysql-devel
5--执行CREATE USER 'songqin'@'localhost' IDENTIFIED BY 'songqin';
报错:bash: CREATE: command not found
1--问题排查
1---执行mysql -u root -p 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
1--一般这个错误是由密码错误引起,解决的办法就是重置密码。第一步跳过密码认证
1---#vim /etc/my.cnf(注:windows下修改的是my.ini)
2--在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,如下图所示:
保存文档并退出:#:wq
3--接下来我们需要重启MySQL:/etc/init.d/mysqld restart(有些用户可能需要使用/etc/init.d/mysql restart)
4--重启之后输入#mysql即可进入mysql
5--接下来就是用sql来修改root的密码,
mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit
到这里root账户就已经重置成新的密码了。需要注意的是,如果执行mysql> update user set password=password("你的新密码") where user="root";
报错:ERROR 1054 (42S22): Unknown column 'password' in 'field list' ,错误的原因是 5.7版本下的mysql数据库下已经没有
password这个字段,password字段改成了authentication_string。
6--编辑my.cnf,去掉刚才添加的内容,然后重启MySQL。大功告成!
3-在mysql下输入--CREATE USER 'songqin'@'localhost' IDENTIFIED BY 'songqin'; 报错---ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 参考网上的方法,执行:alter user 'root'@'localhost' identified by 'root'; 至此,大功告成!!!
mysql初始化安装之后,执行语句报错:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql需要修改初始密码,执行修改用户密码语句,
alter user 'root'@'localhost' identified by 'root';
参考的文章如下,在此表示感谢!!
重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) - 古木堂 - 博客园 https://www.cnblogs.com/gumuzi/p/5711495.html
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. - TIMLONG - 博客园
http://www.cnblogs.com/timlong/p/9323489.html
mysql5.7.18.1修改用户密码报错ERROR 1054 (42S22): Unknown column 'password' in 'field list'解决办法 - wangn - 博客园 https://www.cnblogs.com/wangbaobao/p/7087032.html
---恢复内容结束---