1、安装包
下载网址:http://dev.mysql.com/downloads/mysql/
mysql-5.1.38.tar.gz(版本:5.1.38)
2、添加mysql用户与群
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
3、解压与编译
tar zxvf mysql-5.1.38.tar.gz
cd mysql-5.1.38/
./configure --prefix=/usr/local/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=all
make && make install
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
4、创建MySQL数据库存放目录、以mysql用户帐号的身份建立数据表
mkdir -p /usr/local/mysql/data/
chown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
5、my.cnf配置文件(mysql相关文档均放在/usr/local/mysql/share/mysql/)
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
vi /etc/my.cnf
在[client]下面增加一行:
[client]
default-character-set = utf8
在[mysqld]下面增加三行:
[mysqld]
default-character-set = utf8
6、创建管理MySQL数据库的shell脚本
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysql
chown root:root /etc/rc.d/init.d/mysql
vi /etc/rc.d/init.d/mysql
# If you change base dir, you must also change datadir. These may get
# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
7、启动MySQL
service mysql start
8、修改 mysql 的 root 密码:
/usr/local/mysql/bin/mysqladmin -u root password 'password'
9、通过命令行登录管理MySQL服务器(提示输入密码并回车):
/usr/local/mysql/bin/mysql -u root -p
10、输入以下SQL语句,创建一个向特定ip开放的用户和密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@remote-ip IDENTIFIED BY 'password';
11、测试navicat:test connection
12、修改mysql中的user表root@remote-ip的Grand-prv为Y
13、重启mysql
service mysql restart