ubuntu12.04 安装mysql

1.下载MySql

http://www.mysql.com/downloads/mysql/ 我在这里下载的是5.6.11的64位mysql-5.6.11-linux-glibc2.5-x86_64.tar.gz

2.解压缩

解压缩至/usr/local/mysql-5.6.11

cd /usr/loca/
sudo tar -xvzf ./mysql-5.6.11-linux-glibc2.5-x86_64.tar.gz
sudo mv mysql-5.6.11-linux-glibc2.5-x86_64 mysql.5.6.11

3.创建用户组

sudo groupadd mysql
sudo useradd -r -g mysql mysql

4.改变/usr/local/development/mysql-5.6.11目录的所有者为mysql

sudo chown -R mysql:mysql /usr/local/mysql-5.6.11/

5.安装共享库libaio1

sudo apt-get install libaio1

6.使用mysql_install_db初始化授权表。此操作只是在MySQL初次安装时才需要执行,如果是已存在的安装,则可以跳过此步骤,否则会覆盖先前的授权信息。

sudo ./mysql-5.6.11/scrpits/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.6.11/ --datadir=/usr/local/mysql-5.6.11/data/

7.创建符号链接/usr/local/mysql到/usr/local/development/mysql-5.6.11

cd /usr/local
sudo ln -s /usr/local/mysql-5.6.11 mysql
sudo chown -R mysql:mysql mysql

8.配置mysql服务,然后启动

cd /etc/init.d
sudo ln -s /usr/local/mysql-5.6.11/support-files/mysql.server
sudo /etc/init.d/mysql.server start

9.查看mysql运行状态及使用mysqladmin version命令检查一下是否可以连接mysql

ps -aux|grep mysql
cd /usr/local/mysql
bin/mysqladmin version

10.每次开机时自动启动mysql服务

sudo update-rc.d mysql.server defaults

11.登陆数据库并设置初始密码为123456,建立utf-8 database,hive用的是latin1

mysql -h localhost -u root -p
密码空--回车
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
create database hive character set utf8 collate utf8_bin;
alter database hive character set latin1;