ubuntu 安装mysql

参考:http://dev.mysql.com/doc/refman/5.1/zh/installing.html#installing-binary

sudo apt-get install mysql-server mysql-client

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo netstat -tap | grep mysql
sudo /etc/init.d/mysql restart


01. 安装前线卸载清理下
02. 下载二进制包mysql-XXX.tar.gz
03. sudo groupadd mysql
04. mkdir /home/mysql
    mkdir -p /usr/local/mysql/data
    mkdir -p /usr/local/mysql/tmp
05. sudo useradd -r -g mysql mysql
06. cp mysql-XXX.tar.gz /usr/local
07. tar zxvf mysql-XXX.tar.gz
    cd mysql-XXX
    ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-mysqld-user=mysql --with-charset=utf8 --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
    make
    make install
08. ln -s mysql-XXX mysql
09. cd /usr/local/mysql
10. chown -R mysql .
11. chgrp -R mysql .
12. sudo scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
13. 启动 &代表后台运行
    bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf &
    停止
     bin/mysqladmin shutdown -u root -p
14. bin/mysqladmin -u root password 'liudong'
15. cp support-files/my-medium.cnf ./my.cnf
16. sudo cp support-files/mysql.server /etc/init.d/mysql.server

如果出现error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'解决办法:
ln -s /usr/local/mysql/tmp/mysql.sock /tmp/mysql.sock
chmod 755 /tmp/mysql.sock

你可能感兴趣的:(ubuntu)