俗话说:“天生我才必有用”,可又有话说:“好记性不如烂指头”,在这个科技日益增长的时代,少不了在服务器上部署东西,在天才的猴子也有记性差的时候,浅浅在此整理下linux环境下安装mysql数据库,方便以后查找。
安装mysql
tar -xvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.7.10-linux-glibc2.5-x86_64 mysql
mkdir /usr/local/soft/mysql/data
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
chown -R mysql.mysql /usr/local/soft/mysql/
bin/mysql_install_db --user=mysql --basedir=/usr/local/soft/mysql/ --datadir=/usr/local/soft/mysql/data/
cp -a ./support-files/my-default.cnf /etc/my.cnf
cp -a ./support-files/mysql.server /etc/init.d/mysqld
vi /etc/my.cnf
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
service mysqld start
cat /root/.mysql_secret
bin/mysql -uroot -p(password)
./bin/mysqladmin -u root -p (newpassword) 1*btp)>H-e,y
mysql登录授权
shell> bin/mysql -uroot -pp@ssw0rd
mysql> use mysql
mysql> update user set host='%' where user='root';
mysql> select host,user from user;
mysql> quit
shell> service mysqld restart
update user set authentication_string=password('p@ssw0rd') where user = 'root';
alter user 'root'@'localhost' identified by 'p@ssw0rd';
作者:浅浅
网友评论