yum install cmake ncurses-devel.x86_64 bison-devel.x86_64 libaio-devel.x86_64 gcc-c++.x86_64
wget -O /usr/local/src/mysql-5.5.25a.tar.gz http://ftp.nchu.edu.tw/Unix/Database/MySQL/Downloads/MySQL-5.5/mysql-5.5.32.tar.gz
####权限
useradd mysql mkdir -p /opt/mysqldata/ /usr/local/mysql5.5/ chown -R mysql:root /usr/local/mysql5.5/ chown -R mysql:root /opt/mysqldata/ mkdir -p /var/run/mysqld tar zxvf mysql-5.5.25a.tar.gz cd mysql-5.5.25a
####配置
CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \ cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/opt/mysqldata \ -DMYSQL_USER=mysql \ -DSYSCONFDIR=/usr/local
全部编码
-DEXTRA_CHARSETS=all \
只有utf-8和GBK
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
####编译
make
####安装
make install
###初始化数据库
/usr/local/mysql5.5/scripts/mysql_install_db --user=mysql --datadir=/opt/mysqldata --basedir=/usr/local/mysql5.5/ cp ./support-files/my-huge.cnf /usr/local/mysql5.5/my.cnf
###修改my.cnf
[mysqld_safe] #log-error=/opt/logs/mysql/mysqld.log [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /opt/mysqldata/ wait_timeout=864000 interactive-timeout=864000 max_connections=2048
###启动
/usr/local/mysql5.5/bin/mysqld_safe --defaults-file=/usr/local/mysql5.5/my.cnf &
###关闭
/usr/local/mysql5.5/bin/mysqladmin --host=127.0.0.1 --port=3306 --user=xxx --password shutdown
设置密码
/usr/local/mysql5.5/bin/mysqladmin -uroot password '360buy'
参看密码是否生效
/usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
进不去了,说明已经生效
使用密码登录
/usr/local/mysql5.5/bin/mysql -uroot -p
输入刚刚新建的密码,就可以进去了
添加root的远程访问
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; mysql>flush privileges;