查看Linux版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)因为Centos7 里面没有mysql的yum源,重新下载建立yum源,然后创建mysql数据库
[root@localhost ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@localhost ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@localhost ~]# yum install mysql-server
登录数据库
[root@localhost opt]# mysql -u root
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)注意:/var/lib/mysql的访问权限问题,将该文件夹的所有者改为root用户
[root@localhost opt]# chown -R root:root /var/lib/mysql
重启mysqld 服务
[root@localhost opt]# service mysqld restart
重新登录mysql库
[root@localhost opt]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.34 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> use mysql
mysql> update user set password=password(“123456”) where user=’root’;
Query OK, 4 rows affected (0.15 sec)
Rows matched: 4 Changed: 4 Warnings: 0mysql> exit
Bye
[root@localhost opt]#修改防火墙配置
Centos 7 安装mysql数据库
最新推荐文章于 2025-05-12 13:48:43 发布