Centos 7 安装mysql

先检查系统是否装有mysql

rpm -qa | grep mysql 这里执行安装命令是无效的,因为centos-7默认是Mariadb,所以执行以下命令只是更新Mariadb数据库 yum install mysql 删除 yum remove mysql

下载mysql的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

安装mysql-community-release-el7-5.noarch.rpm包

sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm

安装mysql

sudo yum install mysql-server

这里可能会报错 请注意

Error: Package: mysql-community-libs-5.6.35-2.el7.x86_64 (mysql56-community)
           Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
           Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
           Requires: systemd
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
           Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Error: Package: mysql-community-client-5.6.35-2.el7.x86_64 (mysql56-community)
           Requires: libc.so.6(GLIBC_2.17)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

解决方法如下:

yum install glibc.i686 yum list libstdc++*

然后登陆 没有密码直接回车跳过 mysql -u root -p

登录时有可能报这样的错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2),原因是/var/lib/mysql的访问权限问题。下面的命令把/var/lib/mysql的拥有者改为当前用户:

sudo chown -R openscanner:openscanner /var/lib/mysql

重启mysql service mysqld restart

这里密码设置的为root

mysql > use mysql;
mysql > update user set password=password('root') where user='root';
mysql > exit;

再重启 登陆mysql 加上远程访问权限 为root添加远程连接的能力。链接密码为 “root”(不包括双引号)

mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  

最后最后 非常重要 查询不区分大小写表名

vim /etc/my.cnf 在[mysqld]节点下,加入一行: lower_case_table_names=1 WX20190710-151220@2x 重启数据库 连接工具测试连接 5E7E7FBB-4F4B-4C82-83E0-F98203469C7A

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×