Linux mysql 安装

 

1、下载Linux 版本的mysql

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

2、解压

tar -xvf mysqlxx.tar.gz

3.复制解压后的mysql目录到系统的本地软件目录:

执行命令:cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r

注意:目录结尾不要加/

4、添加系统mysql组和mysql用户:

执行命令:groupadd mysql和useradd -r -g mysql mysql

5、安装数据库:

进入安装mysql软件目录:执行命令 cd /usr/local/mysql

修改当前目录拥有者为mysql用户:执行命令 chown -R mysql:mysql ./

安装数据库:执行命令 ./scripts/mysql_install_db --user=mysql

问题

[root@localhost mysql-5.6.34]# ./scripts/mysql_install_db --user=mysql
Installing MySQL system tables..../bin/mysqld: error while loading shared librar                                                                                        ies: libaio.so.1: cannot open shared object file: No such file or directory
解决方法:yum install libaio* -y

修改当前目录拥有者为root用户:执行命令 chown -R root:root ./

修改当前data目录拥有者为mysql用户:执行命令 chown -R mysql:mysql data

到此数据库安装完毕

6.启动数据库

[root@localhost bin]# service mysql start
Starting MySQL.touch: cannot touch '/var/log/mariadb/mariadb.log': No such file                                                                                         or directory
chmod: cannot access '/var/log/mariadb/mariadb.log': No such file or directory
touch: cannot touch '/var/log/mariadb/mariadb.log': No such file or directory
chown: cannot access '/var/log/mariadb/mariadb.log': No such file or directory
/usr/local/mysql/mysql-5.6.34/bin/mysqld_safe: line 129: /var/log/mariadb/mariad                                                                                        b.log: No such file or directory
/usr/local/mysql/mysql-5.6.34/bin/mysqld_safe: line 166: /var/log/mariadb/mariad                                                                                        b.log: No such file or directory
touch: cannot touch '/var/log/mariadb/mariadb.log': No such file or directory
chown: cannot access '/var/log/mariadb/mariadb.log': No such file or directory
chmod: cannot access '/var/log/mariadb/mariadb.log': No such file or directory
/usr/local/mysql/mysql-5.6.34/bin/mysqld_safe: line 129: /var/log/mariadb/mariad                                                                                        b.log: No such file or directory
 ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.loca                                                                                        ldomain.pid).

解决办法
[root@localhost bin]# mkdir /var/log/mariadb
[root@localhost bin]# chmod 700 /var/log/mariadb
[root@localhost bin]# service mysql start
Starting MySQL. SUCCESS!
启动成功

7访问数据库

[root@localhost mysql-5.6.34]# mysql -uroot -p
-bash: mysql: 未找到命令
[root@localhost mysql-5.6.34]# ln -s /usr/local/mysql/mysql-5.6.34/bin/mysql /usr/bin

[root@localhost mysql-5.6.34]# mysql -uroot -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

解决办法,先找到mysql.sock文件
[root@localhost mysql-5.6.34]# find / -name mysql.sock
/var/lib/mysql/mysql.sock

建立软连接
[root@localhost mysql-5.6.34]# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
[root@localhost mysql-5.6.34]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
链接成功

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值