ubuntu mysql

1. 下载mysql-5.5.15-linux2.6-i686.tar.gz

http://www.mysql.com


2. 配置文件夹

tar -xfz mysql-5.5.15-linux2.6-i686.tar.gz
mv mysql-5.5.15-linux2.6 ~/mysql
sudo ln -s ~/home/mysql /usr/local/mysql


3. 配置linux用户以及文件夹属性

sudo groupdadd mysql
sudo useradd -r -g mysql mysql
cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo scripts/mysql_install_db --user=mysql
sudo chown -R root .
sudo chown -R mysql data

4. 装补丁

sudo apt-get install libaio1

5. 拷贝mysql配置文件

sudo cp support-files/my-medium.cnf /etc/my.cnf
sudo cp support-files/mysql.server /etc/init.d/mysql

6. 配置mysql用户

sudo ./bin/mysqld_safe --skip-grant-tables &
./bin/mysql
#配置脚本
UPDATE user SET Password=PASSWORD('tianshengwocaibiyouyong2010') where USER='root';
flush privileges;
grant all privileges on *.* to 'root'@'%' identified by '123';
flush privileges;
grant all privileges on *.* to 'newuser'@'%' identified by '123';
flush privileges;
grant all privileges on *.* to 'root'@'localhost' identified by '123';
flush privileges;
grant all privileges on *.* to 'newuser'@'localhost' identified by '123';
flush privileges;
quit;

测试

sudo /etc/init.d/mysql start
mysql -uroot
账号:root
密码:tianshengwocaibiyouyong

FAQ

1. 如果不能启动,需要指定basedir
sudo ./bin/mysqld_safe --basedir=/usr/local/mysql
2. 如果不能远程访问
a. 可能是没有配置远程账号问题
b. 可能需要直接指定bind-address=0.0.0.0参数
sudo ./bin/mysqld --basedir=/usr/local/mysql --bind-address=0.0.0.0
3. 安装后账号不能本地登陆
a. 需要添加grant all privileges on *.* to 'newuser'@'%' identified by 'tianshengwocaibiyouyong2010';flush privileges;
4. 安装后发现设置了账号,但没有生效,则需要flush privileges;
5. ubuntu11.10-desktop-i386版本安装mysql-5.5.15-linux2.6-i686.tar.gz,可能出现安装启动不了情况,用【2】解决






原文地址:https://www.cnblogs.com/lavieenrose/p/2318035.html