在xshell连接到服务器后输入sudo su 进入root目录,逐条输入下面的指令,亲测及其好用
yum -y install mysql mysql-server mysql-devel php-mysql
chkconfig --level 35 mysqld on
/etc/init.d/mysqld start
mysql_secure_installation
Enter current password for root (enter for none): ----》默认为空密码直接回车
Set root password? [Y/n] y ----》设置root密码
New password:
Re-enter new password:
Remove anonymous users? [Y/n] y ----》禁止匿名访问
Disallow root login remotely? [Y/n] y ----》不允许root远程访问
Remove test database and access to it? [Y/n] y ----》删除测试数据库test
Reload privilege tables now? [Y/n] y ----》重新加载授权信息
创建的名为mysql数据库中就会存在新创建的用户信息,保存用户信息的数据库名字一般为user,这里创建的是mysql,用户名一般为root,密码可以设置也可以为空