Centos 7 安装mysql5.7.24二进制 版本的方法及解决办法
Mysql二进制安装方法
下载mysql
https://dev.mysql.com/downloads/mysql/
1.解压包
tarxfmysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
2.实际生产环境
mvmysql-5.7.24-linux-glibc2.12-x86_64/usr/local/mysql5.7
a.新增Mysql用户组
groupaddmysql
b.新增用户
opt]#useradd-r-gmysqlmysql
C.给mysql目录权限
chown-Rmysql:mysqlmysql5.7
3.到初始化环境的目录
Cd/home/usr/local/mysql5.6/ mkdirdata mkdirlog chown-Rmysql:mysqlmysql5.7
4.初始化数据和指定安装目录和数据目录
./bin/mysqld--initialize--user=mysql--basedir=/usr/local/mysql5.7/--datadir=/usr/local/mysql5.7/data/
6复制启动文件
cpmysql.server/etc/init.d/mysqld chmod+x/etc/init.d/mysqld
7.修改启动路径
vi/etc/init.d/mysqld basedir=/usr/local/mysql5.7 datadir=/usr/local/mysql5.7/data
8.增加环境变量(最下面添加)l
vi/etc/profile exportMYSQL_HOME="/usr/local/mysql5.7" exportPATH="$PATH:$MYSQL_HOME/bin"
9.刷新配置文件
source/etc/profile
修改配置文件
vi/etc/my.cnf [client] port=3306 [mysqld] basedir=/usr/local/mysql5.7 datadir=/usr/local/mysql5.7/data #socket=/usr/local/mysql5.7/mysql.sock socket=/tmp/mysql.sock user=mysql #skip-grant-tables #Disablingsymbolic-linksisrecommendedtopreventassortedsecurityrisks symbolic-links=0 #Settingsuserandgroupareignoredwhensystemdisused. #Ifyouneedtorunmysqldunderadifferentuserorgroup, #customizeyoursystemdunitfileformariadbaccordingtothe #instructionsinhttp://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/usr/local/mysql5.7/log/mysqld.log pid-file=/usr/local/mysql5.7/data/mysqld.pid # #includeallfilesfromtheconfigdirectory # !includedir/etc/my.cnf.d
11.添加开启自启
chkconfig--addmysqld chkconfigmysqldon
12.启动mysqld
servicemysqldstart netstat-anpt
13.修改密码(密码初始化的时候有个密码)
2018-11-02T02:07:44.574468Z1[Note]Atemporarypasswordisgeneratedforroot@localhost:lXyB0%fi#9-S(这个就是密码) mysql>helpcontents ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement. mysql>helpcontents ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement. mysql>showdatabases; ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.
解决办法
1、修改用户密码
mysql>alteruser'root'@'localhost'identifiedby'youpassword';
或者
mysql>setpassword=password("youpassword");
2、刷新权限
mysql>flushprivileges; mysql>helpcontents
总结
以上所述是小编给大家介绍的Centos7安装mysql5.7.24二进制版本的方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!