yum安装mysql5.7 和 pdo_mysql扩展

yum安装mysql5.7

1,安装mysql源:

yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum repolist enabled | grep “mysql.*-community.*”

2,安装mysql:

yum -y install mysql-community-server mysql-community-devel

3,启动mysql:

service mysqld start

检查mysql启动是否正常:

service mysqld status 或者 ps -ef | grep mysql

设置mysqld服务开机自启动:

systemctl enable mysqld.service

检查mysqld开机自启动是否设置成功:

systemctl list-dependencies | grep mysqld

查看密码和修改密码
查看mysql的root账号的密码 grep ‘temporary password’ /var/log/mysqld.log

登录mysql mysql -uroot -p

修改密码 ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’;
修改root用户可远程登录 GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
刷新 flush privileges;

注意事项 :
select @@log_error;
如果有报错 :Your password does not satisfy the current policy requirements

这个与validate_password_policy的值有关。

默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。

可以设置:
set global validate_password_policy=0;
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘123456’;
select @@validate_password_length;

SHOW VARIABLES LIKE ‘validate_password%’;
mysql的默认路径 : /usr/include/mysql

安装pdo_mysql 扩展
phpize

./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr
make && make_install
扩展路径 : eg : /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/
php.ini 添加 extension=pdo_mysql
ps aux| grep php
eg :
www 5415 0.0 0.1 260284 8052 ? Ss Aug23 0:41 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
www 24967 0.0 0.0 112648 956 pts/1 S+ 10:14 0:00 grep –color php
www 29280 0.0 0.3 390556 24516 ? S Sep04 0:08 php-fpm: pool www
www 30740 0.0 0.3 390480 24564 ? S Sep05 0:07 php-fpm: pool www
www 31173 0.0 0.3 391704 26424 ? S Sep05 0:06 php-fpm: pool www

重启php kill -USR2 5415

你可能感兴趣的:(mysql)