非root用户安装配置mysql

时间:2023-02-02 16:06:26

        mysql的安装参考这篇日志 http://blog.csdn.net/zuocheng_liu/article/details/6654694#t11

        下面重点说明非root用户配置mysql,下面以用户liuzuocheng为例。

1.拷贝一个conf文件到mysql目录,cp /home/liuzuocheng/local/mysql/share/mysql/my-large.cnf /home/liuzuocheng/local/mysql/my.cnf
2.修改my.cnf的port,和mysql.sock的目录,下面是我的配置

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 83306
socket = /home/liuzuocheng/var/mysql/mysql.sock
#
# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 83306
socket = /home/liuzuocheng/var/mysql/mysql.sock
basedir = /home/liuzuocheng/local/mysql
datadir = /home/liuzuocheng/var/mysql/data
log-error = /home/liuzuocheng/var/mysql/logs/mysql_error.log
pid-file = /home/liuzuocheng/var/mysql/mysql.pid
user = liuzuocheng


3.回到mysql目录,bin/mysql_install_db --defaults-file=./my.cnf
4.安装db,bin/mysql_install_db --defaults-file=./my.cnf
5.启动db,bin/mysqld_safe --defaults-file=./my.cnf &, 看看tmp/mysql.sock 有这个文件,就启动成功
6.启动客户端,bin/mysql -u root -S ./tmp/mysql.sock
7.

mysql> show engines; #可以看到engine的类型 
mysql> show databases; #可以看到mysql下面的数据库。