centos7以上的版本没有安装mysql,无法使用centos5一样用rpm install mysql.rpm来安装软件
正确安装方法:
1、从社区下载最新版安装包
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
2、查看当前可用的mysql安装资源
yum repolist enabled | grep "mysql.*-community.*"
如果显示如下信息则说明有可用mysql安装包
3、yum安装mysql
yum -y install mysql-community-server
4、安装完成后进行查询验证是否安装成功
rpm -qa|grep -i mysql
显示信息如下则说明安装成功
5、安装完成后进行mysql配置
安装完MySQL后,需要进行一些基础配置工作:
#######安装成功后,将其加入开机启动
[root@typecodes ~]# systemctl enable mysqld
#######启动mysql服务进程
[root@typecodes ~]# systemctlstartmysqld
#######配置mysql(设置密码等)
[root@typecodes ~]# mysql_secure_installation
NOTE: RUNNINGALLPARTSOFTHIS SCRIPTISRECOMMENDEDFORALLMySQL
SERVERSINPRODUCTION USE! PLEASEREADEACH STEP CAREFULLY!
InordertologintoMySQLtosecure it, we'll need the current
password for the root user. If you've just installed MySQL,and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] y [设置root用户密码]
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y [删除匿名用户]
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y [禁止root远程登录]
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y [删除test数据库]
- Dropping test database...
ERROR 1008 (HY000) at line 1: Can'tdropdatabase'test'; database doesn't exist
... Failed! Not critical, keep moving...
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reloadprivilege tables now? [Y/n] y [刷新权限]
... Success!
Alldone! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
6、配置完成后进行验证是否可登陆
mysql -u root -p123456 【root为用户名,123456为配置时设置的密码:注意-p和密码之间不要有空格】
显示如下则说明用户名密码设置可用并登陆成功