源码编译安装mysql(适用于5.5全部版本)
1.首先安装cmake
# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz # tar zxvf cmake-2.8.4.tar.gz # cd cmake-2.8.4 # ./configure # make # make install
# mkdir /opt/mysql # mkdir /data/mysql/data
# groupadd mysql # useradd -g mysql mysql
# chown mysql:mysql -R /data/mysql/data
# tar zxvf mysql-5.5.13.tar.gz# cd mysql-5.5.13
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DSYSCONFDIR=/opt/mysql/etc -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
# yum install ncurses-devel
# rm -fr CMakeCache.txt
# make# make install
# mkdir /opt/mysql/log # mkdir /opt/mysql/etc # cp support-files/my-medium.cnf /opt/mysql/etc/my.cnf
# chmod 755 scripts/mysql_install_db # scripts/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/data/mysql/data/
# mkdir /opt/mysql/init.d # cp support-files/mysql.server /opt/mysql/init.d/mysql
# chmod +x /opt/mysql/init.d/mysql
# /opt/mysql/init.d/mysql start
rm -fr /data/mysql/datamkdir /data/mysql/data
chmod 755 scripts/mysql_install_dbscripts/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/data/mysql/data///授权chmod +x /opt/mysql/init.d/mysql//启动/opt/mysql/init.d/mysql start
/mysql-bin.index' not found (Errcode: 13
# chmod u+x /opt/mysql/data
# vim /opt/mysql/init.d/mysql
datadir=/data/mysql/data
# chmod u+x /data/mysql/data
# /opt/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
# /opt/mysql/bin/mysqladmin -u root password 'new-password'
cp /opt/mysql/init.d/mysql /etc/init.d/mysqlchmod 755 /etc/init.d/mysqlchkconfig mysql on//重启生效reboot
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';
grant all privileges on *.* to root@'%' identified by 'password';
grant all privileges on *.* to root@'192.168.1.125' identified by 'password';
grant all privileges on *.* to root@'192.168.1.%' identified by 'password';
/opt/mysql/bin/mysql -uroot -p'new-password' mysql>use mysql; //选择系统数据库mysql mysql>select Host,User,Password from user; //查看所有用户 mysql>delete from user where password=""; mysql>flush privileges; mysql>select Host,User,Password from user; //确认密码为空的用户是否已全部删除 mysql>exit;