MySQL安装

压缩包安装(建议查看mysql官方文档)

1.官方文档位置 https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

shell>groupadd mysql 

shell>useradd -r -g mysql -s /bin/false mysql 

shell>cd /usr/local 

shell>tar zxvf  ***.tar.gz 

shell> mv *** /usr/local/mysql

shell> cd /usr/local/mysql

shell>cd mysql 

shell>mkdir mysql-files 

shell>chmod 750 mysql-files 

shell>chown -R mysql.

shell>chgrp -R mysql.

shell>bin/mysql_install_db --user=mysql # 适合MySQL 5.7.5

shell>bin/mysqld --initialize --user=mysql #5.7.6以上版本 MySQL 5.7.6 and up

# 注意保存临时密码!!!

shell>bin/mysql_ssl_rsa_setup  # MySQL 5.7.6 and up

shell>chown -R root.

shell>chown -R mysql data mysql-files 

shell>bin/mysqld_safe --user=mysql & 

# Next command is optional

shell>cp support-files /mysql.server /etc/init.d/mysql

2.账号测试和授权

bin/mysql -u root -p

进入mysql之后很多操作都会提示要重新设置面码

mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

    其它参考方案:

    SET PASSWORD = PASSWORD('your new password');

    ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

    flush privileges;

远程访问权限:

grant all privileges on *.* to 'root' @'%' identified by '密码' with grant option;

flush privileges;

SELECT User, Host, HEX(authentication_string) FROM mysql.user;

这里用外网ip访问是否可以访问,如果连接不上,十有八九是防火墙的问题

service iptables stop        临时关闭防火墙

chkconfig iptables off      永久关闭防火墙

3.卸载mysql

1.关闭进程

    service mysql stop

2.查看安装目录

    whereis mysql

    删除目录

        rm -rf mysql

3.删除用户及组

    id mysql

    userdel mysql

4.删除配置文件

    rm -rf /etc/my.cnf

    rm -rf /etc/init.d/mysql*

你可能感兴趣的:(MySQL安装)