LNMP之Mysql源码编译安装
LNMP之Mysql源码编译安装
yum install -y gcc gcc-c++ make tar openssl openssl-devel cmake ncurses ncurses-devel
useradd -s /sbin/nologin mysql
wget 'https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39.tar.gz'
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
cp support-files/mysql.server /etc/init.d/mysqld
export PATH=$PATH:/usr/local/mysql/bin/
slow_query_log_file=/data/mysql/mysql-slow.log
innodb_flush_log_at_trx_commit = 2
log-error=/data/mysql/mysqld.log
pid-file=/data/mysql/mysqld.pid
chown -R mysql:mysql /usr/local/mysql /data/mysql/
yum install -y perl-Module-Install
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql/
使用systemctl管理mysqld,/usr/lib/systemd/system/mysqld.service
ExecStart=/etc/init.d/mysqld start
查看监听:netstat -tulnp | grep mysql
查看日志:tail -f /data/mysql/mysqld.log
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.237.%' IDENTIFIED BY 'zabbixpwd' WITH GRANT OPTION;
mysql -h 192.168.237.49 -uroot -pzabbixpwd -A
LNMP的环境验收,/usr/local/nginx/html/test_mysql.php
$link=mysql_connect("127.0.0.1","root","zabbixpwd");
从PHP5.0开始就不推荐使用mysql_connect()函数,到了php7.0则直接废弃了该函数,替代的函数是:
mysqli_connect();
用法是:
$con=mysqli_connect("localhost","my_user","my_password","my_db");
官方的描述连接:http://php.net/manual/en/function.mysqli-connect.php
正确的测试代码:
<?PHP
$conn=mysqli_connect("localhost","root","root");
if($conn){
echo"ok";
}else{
echo"error";
}
?>
本文地址:https://blog.csdn.net/lm19770429/article/details/109464538
推荐阅读