PHP去MySQL中读取数据是个“动态”请求过程。mysql
用二进制免编译安装(对性能没有较高的要求的状况下)Mysql5.7linux
[root@test-a ~]# uname -a # 查看系统位数 Linux test-a 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux [root@test-a ~]# cd /usr/local/src/ # 下载二进制包 [root@test-a src]# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz [root@test-a src]# tar -zxvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz # 把解压后的目录重命名mysql后移动到/usr/local下 [root@test-a src]# mv mysql-5.7.23-linux-glibc2.12-x86_64 /usr/local/mysql [root@test-a mysql]# useradd mysql # 建立mysql用户 [root@test-a mysql]# mkdir /data/ # 为mysql建立数据存储目录 [root@test-a mysql]# ./bin/mysql_install_db # 须要指定数据目录和建议使用mysqld --initialize来初始化数据库 2018-11-12 06:33:14 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2018-11-12 06:33:14 [ERROR] The data directory needs to be specified. [root@test-a mysql]# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql 2018-11-11T22:37:03.945687Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-11-11T22:37:06.436762Z 0 [Warning] InnoDB: New log files created, LSN=45790 2018-11-11T22:37:06.779631Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-11-11T22:37:06.842918Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 519df254-e602-11e8-91f0-000c29b95699. 2018-11-11T22:37:06.845661Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2018-11-11T22:37:06.847683Z 1 [Note] A temporary password is generated for root@localhost: (a1ckckbsd2A # 数据库初始化完成 [root@test-a mysql]# cp support-files/mysql.server /etc/init.d/mysqld # 拷贝mysql启动脚本到/etc/init.d/下并重命名为mysqld [root@test-a mysql]# vi /etc/init.d/mysqld #更改两行配置以下 # basedir=/usr/loca/mysql # datadir=/data/mysql [root@test-a mysql]# chkconfig --add mysqld # 设置mysqld之后启动为跟随系统自启动 [root@test-a mysql]# chkconfig --list Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'. iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off # 新建mysql 配置文件/etc/my.cnf(有则清空),添加以下内容 [mysql] socket = /usr/local/mysql/mysql.sock # The MySQL server [mysqld] port = 3306 socket = /usr/local/mysql/mysql.sock #skip-grant-tables datadir=/usr/local/mysql/data log-error=/usr/local/mysql/db.err pid-file=/usr/local/mysql/mysqld.pid character-set-server = utf8 [root@test-a lib]# service mysqld start #启动报错,添加对应的文件db.err Starting MySQL.2018-11-11T23:24:48.581799Z mysqld_safe error: log-error set to '/usr/local/mysql/db.err', 't exists. Create writable for user 'mysql'. ERROR! The server quit without updating PID file (/usr/local/mysql/mysqld.pid). [root@test-a lib]# touch db.err [root@test-a lib]# chown mysql:mysql db.err [root@test-a mysql]# service mysqld start # 再次失败 Starting MySQL................................................................... ERROR! The server quit wPID file (/usr/local/mysql/mysqld.pid). #是由于mysql目录的文件须要属于mysql用户 [root@test-a mysql]# chown mysql:mysql -R . [root@test-a mysql]# service mysqld start Starting MySQL......... SUCCESS! #另一种启动方式,其中--defaults-file必须紧接着命令后面,能够没有,默认/etc/my.cnf [root@test-a mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & # 中止服务 [root@test-a mysql]# service mysqld stop Shutting down MySQL.. SUCCESS! # 另一种方法 [root@test-a mysql]# killall mysqld # 不要使用kill -9 pid,有可能丢数据