lamp or lnmp 环境搭建,如果mysql 是独立安装的则需要授权:
- 单独一台服务器独立安装mysql
- 安装后,优化服务器。
- 授权
实例如下:
创建用户
CREATE USER demo IDENTIFIED BY “passwd123”;
授权使用mysql数据库下面的所有表
GRANT ALL PRIVILEGES ON mysql.* TO ‘demo‘@‘%‘IDENTIFIED BY ‘passwd123‘WITH GRANT OPTION;
FLUSH PRIVILEGES;
-------------------------------------------------------------------------------------------
实例二
授权所有的数据库给myuser连接
CREATE USER myuser IDENTIFIED BY “mypassword”;
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
实例三
授权所有的数据库给myuser从192.168.1.3上连接
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘10.89.1.30‘IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
4.web服务器连接测试
[[email protected] blog]# vi oldboy_mysql.php
<?php
$link_id=mysql_connect(‘10.89.1.30‘,‘myuser‘,‘mypassword‘) or mysql_error();
if ($link_id) {
echo "mysql _OK()";
}
else {
echo "mysql _error()";
}
?>