mysql-5.7.10 linux 安装教程
经验与学习 2015/12/29 16:37:28 点击:不统计
原载于:文章来源:www.forasp.cn网站制作学习
下载 mysql http://mirrors.sohu.com/mysql/ mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
下载解压后,放到 /webserver/mysql中 注意,glibc版本的Mysql,不是编译版的,是直接编译好的,相当于windows的绿色版
CentOS默认yum源已经没有mysql-server了.而用mariadb代替,而2个数据库冲突,所以要安装mysql,要先卸载mariadb
建立mysql相关的用户和组:
[root@server local]#groupadd mysql
[root@server local]#useradd -s /sbin/nologin -g mysql mysql
添加不用登陆的用户
useradd -s /sbin/nologin <new username>
linux在创建用户是将用户默认的shell指定为/sbin/nologin即可阻止用户登录,命令为
useradd user -s /sbin/nologin,其中-s指定用户的默认shell
如果用户已经存在于系统,用root身份修改/etc/passwd文件,将要阻止的用户的shell改为/sbin/nologin
创建 数据保存文件夹
mkdir /webserver//mysql-5.7.10-linux-glibc2.5-x86_64/data/
初始化数据
bin/mysqld --user=mysql --basedir=/webserver/mysql-5.7.10-linux-glibc2.5-x86_64/ --datadir=/webserver/mysql-5.7.10-linux-glibc2.5-x86_64/data/ --secure-file-priv=/root/ --initialize
在初始化时如果加上 --initial-insecure,则会创建空密码的 root@localhost 账号
--secure-file-priv 指定密码文件夹位置 对应文件夹下就会有 .mysql_secret 文件(5.6以前) 之后的会在log中提示
A temporary password is generated for root@localhost: 6D3Fi_bjFZtn
初始化完毕
启动mysql服务和添加开机启动mysql服务:
添加开机启动:执行命令cp support-files/mysql.server /etc/init.d/mysql,把启动脚本放到开机初始化目录
启动mysql服务:执行命令service mysql start
执行命令:ps -ef|grep mysql 看到mysql服务说明启动成功
错误
/etc/init.d/mysql: line 256: my_print_defaults: command not found
/etc/init.d/mysql: line 276: cd: /usr/local/mysql: No such file or directory
Starting MySQLCouldn't find MySQL server (/usr/local/mysql/[FAILED]ld_safe)
解决
在mysqld 添加配置文件
basedir =/webserver/mysql-5.7.10-linux-glibc2.5-x86_64/
datadir =/webserver/mysql-5.7.10-linux-glibc2.5-x86_64/data
登录mysql 出现找不到socket
在 My.cnf 中 添加[client]
socket=/var/lib/mysql/mysql.sock 跟实际中的一样
登录
mysql -u root -p 登录成功后修改密码
you must reset your password using ALTER USER statement before executing this statement.
修改密码
SET PASSWORD = PASSWORD('123456');
重新登录即可。
学习www.网for站asp制.cn作