由于从所周知的原因,mysql不能在新版centos上用了。
其实很简单,网上很多文章的介绍其实都是来源于官网
它会自动为我们生成repo, 然后复制粘贴就行
image.png
创建repo文件,然后yum install MariaDB-server MariaDB-client就行
- 配置过程
1)先启动服务
systemctl start mariadb
是的,现在建议用systemctl替代service命令
2)再配置mysql_secure_installation
3)设置密码
这里不知道密码,中断了去设置密码
systemctl stop mariadb.service
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
然后输入sql指令
MariaDB [mysql]> update mysql.user set authentication_string=password('255') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
再回来mysql_secure_installation并输入密码,会有以下交互
Remove anonymous users? [Y/n] <– 是否删除匿名用户,生产环境建议删除,所以直接回车
… 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] <–是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
… 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] <– 是否删除test数据库,直接回车
以后这样登录:
mysql -uroot -p 并且输入密码,不能再只使用不安全的不带参数的mysql了
如果需要安装pdo_mysql记得只需要以下一句就可以了,不需要网上说的还要手动编译源码
yum install php-mysql
网友评论