//mysql5.5.20的安装步骤
groupadd -r mysql
useradd -g mysql -s /sbin/nologin -M mysql
tar zvxf /root/mysql-5.5.20-linux2.6-x86_64.tar.gz
mkdir -p /usr/local/mysql
mv mysql-5.5.20-linux2.6-x86_64/* /usr/local/mysql
cd /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/
mkdir -p /data/mysql/data
cd /data/mysql/data
chown -R mysql:mysql /data/mysql/data/
cd /usr/local/mysql/
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql/data
service mysqld start
mysql
use mysql
mysql> UPDATE user SET Password = password('redhat')WHERE User = 'root';
mysql> FLUSH PRIVILEGES;
//添加path路径
export PATH=$PATH:/usr/local/mysql/bin/
#vi ~/.bash_profile
PATH=/usr/local/mysql/bin:$PATH:$HOME/bin
//修改字符集问题
mysql> show variables like 'collation_%';
mysql> show variables like 'character_set_%';
修改配置文件/etc/my.cnf
vi /etc/my.cnf
在[client]下添加
default-character-set=utf8
在[mysqld]下添加
#default-character-set=utf8
character-set-server = utf8
init_connect='SET NAMES utf8'
然后重启mysql服务,再查看即可
service mysqld restart