Linux下Mysql安装配置运行

linux下mysql安装

1.下载地址
https://www.mysql.com/downloads/
选择community server
在这里插入图片描述
默认是最新的8.0几版本
在这里插入图片描述
点击“Looking for” 选择5.6.xx版本
在这里插入图片描述
选择 Linux - Generic 类型
选择 Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive
选择no thanks
在这里插入图片描述
获得的安装包(判断Linux的操作系统位数)在这里插入图片描述

2. 安装mysql

  1. 安装依赖

    #yum -y install perl perl-devel autoconf libaio
    #yum install -y perl-Data-Dumper 
    
  2. 解压 安装包

    # tar zxf mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz
    
  3. 复制解压后的mysql目录到系统的本地软件目录:

    # cp mysql-5.6.43-linux-glibc2.12-x86_64  /usr/local/mysql  -r
      注意:目录结尾不要加/
    
  4. 添加系统mysql组和mysql用户:

       # groupadd mysql
       # useradd -r -g mysql -s /bin/false mysql 
    
  5. 安装数据库:

       5.1) 进入安装mysql软件目录
       	# cd /usr/local/mysql
    
       5.2) 修改当前目录拥有者为mysql用户
            # chown -R mysql:mysql ./
    
       5.3) 安装数据库:
            # ./scripts/mysql_install_db --user=mysql
    
       5.4) 修改当前目录拥有者为root用户 
            # chown -R root:root  ./
    
       5.5) 修改当前data目录拥有者为mysql用户 
            # chown -R mysql:mysql data
    

添加mysql服务开机自启动

	cp support-files/mysql.server /etc/init.d/mysql
	# 赋予可执行权限
	chmod +x /etc/init.d/mysql
	# 添加服务
	chkconfig --add mysql 
	# 显示服务列表
	chkconfig --list 

启动mysql服务:

 # service mysql start

修改mysql的root用户密码,root初始密码为空的:

   # /usr/local/mysql/bin/mysqladmin -u root password ' xxxx123456'

连接数据库 ./mysql -u root -p

在这里插入图片描述

linux中mysql 开通用户远程连接

./mysql -u root -p 
mysql>use mysql;       //使用mysql数据库 
mysql>select host from user where user='root';     //查询root 的host 
mysql>update user set host = '%' where user ='root'; 
mysql>flush privileges; 
mysql>select 'host'   from user where user='root';

在这里插入图片描述
如果还是不能连接【考虑 3306端口是否开启】
使用telnet 尝试端口是否开启
在这里插入图片描述

用root登陆mysql执行如下命令
grant all on sonardb.* to sonar@’%’ identified by ’123456′;
grant all on sonardb.* to sonar@localhost identified by ’123456′;
sonardb替换为你想访问的数据库名,sonar是你的想使用的用户名,123456替换为你的密码,这样就开启了远程访问功能

问题说明

1. 问题一、 ./scripts/mysql_install_db --user=mysql 安装结束后 出现警告消息 (不影响)
在这里插入图片描述
2. 问题二

Starting MySQL.170310 15:33:35 mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', 
however file don't exists.   Create writable for user 'mysql'.
The server quit without updating PID file (/var/lib/mysql/i[FAILED]rkZ.pid).

解决 创建 
mysqld_safe无法启动的解决办法 
 /var/log/mariadb/mariadb.log   创建 这个 文件   
 chown -R mysql:mysql mariadb   分配 权限 mysql 用户  

3. 问题三
在这里插入图片描述

4. 问题四

最近在阿里云远端服务器上搭建mysql数据库  安装时候提示
解决方法是安装autoconf库
执行命令:yum -y install autoconf 

5. 问题五

 [root@localhost bin]# ./mysql
	  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
	解决方法
	[root@localhost bin]# ./mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
	[root@localhost bin]# ./mysql -u root mysql
	mysql> UPDATE user SET Password=PASSWORD('123456') where USER='root'; 
	mysql> FLUSH PRIVILEGES; 
	mysql> quit
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值