http://blog.csdn.net/jerome_s/article/details/52883234
yum 安装MySQL
 
1. 检查安装情况
 
        查看有没有安装过:
        yum list installed MySQL* (有存在要卸载yum remove MySQL*)
        rpm -qa | grep mysql*
 
        查看有没有安装包:
        yum list mysql*
 
2. 安装 MySQL
 
        安装 MySQL 客户端:
        yum -y install mysql
 
        安装 MySQL 服务器端:
        yum -y install mysql-server  mysql-devel
 
3. 配置和启动
 
        数据库字符集设置:
        MySQL 配置文件/etc/my.cnf中加入default-character-set=utf8
    
        启动 MySQL 服务: 
        service mysqld start或者/etc/init.d/mysqld start
 
        设置开机启动:
        添加开机启动:chkconfig --add mysqld;
        开机启动:chkconfig mysqld on;
        查看开机启动设置是否成功chkconfig --list | grep mysql* mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭停止:
 
        停止 MySQL 服务: 
        service mysqld stop
 
4.  MySQL 登陆等权限设置
 
        登录 MySQL 数据库:
        mysq -u root password 123456
 
        首次使用创建root管理员和密码:
        (mysql -u root -p输入密码即可?)
        mysql -u root;
        use mysql ;
        update user set password=password("123456") where user="root";
        flush privileges;
 
        忘记密码:
        service mysqld stop;
        mysqld_safe --user=root --skip-grant-tables;
        这一步骤执行的时候不会出现新的命令行,你需要重新打开一个窗口执行下面的命令
        mysql -u root;
        use mysql ;
        update user set password=password("123456") where user="root";
        flush privileges;
 

如果需要外网可以访问需要再做如下设置:

        授权用户可以从远程登陆
        grant all PRIVILEGES on *.* to root@'%'  identified by 'pwd123';
        flush privileges ;
 
5. 远程访问,开放防火墙的端口号 MySQL
 
        一般开发测试我直接把防火墙关闭,生产的开发对应端口即可:
1
2
3
4
5
6
su root
service iptables stop #关闭防火墙
service iptables status #验证是否关闭
chkconfig iptables off #关闭防火墙的开机自动运行
chkconfig –list | grep iptables #验证防火墙的开机自动运行
vim /etc/sysconfig/selinux # 禁用selinux,将SELINUX=disabled
 
6. Linux MySQL 的几个重要目录
 
        数据库目录 /var/lib/mysql/
        配置文件 /usr/share /mysql(mysql.server命令及配置文件)
        相关命令 /usr/bin(mysqladmin mysqldump等命令)
        启动脚本 /etc/rc.d/init.d/(启动脚本文件mysql的目录)
 
 
7. 删除 MySQL  数据库
 
        如果使用的是 yum 安装的 mysql,需要删除的话,就使用如下命令:
        yum -y remove mysql*
        然后将 /var/lib/mysql文件夹下的所有文件都删除干净,最后再重新执行上面的安装步骤。
 
 

yum 安装 MySQL 指定版本

 
        默认yum只能安装mysql 5.1,我们可以自己配置通过yum安装5.6或者其他版本。
 
1. 查看系统里面有没有mysql 的repo(可以参考上面第一步卸载)
 
        yum repolist all | grep mysql
 
2. 如果没有发现,则需要配置repo
 
        只能有一个是 enabled=1的,其他的都得enabled=0。
        vim /etc/yum.repos.d/mysql-community.repo
        输入如下内容
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
 

3. 再看看是否存在 MySQL 的 repo

 
        yum repolist enabled | grep mysql
        可以看到已经有了。
 
4. 签名
 
        vim /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
        写入如下内容
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.9 (SunOS) mQGiBD4+owwRBAC14GIfUfCyEDSIePvEW3SAFUdJBtoQHH/nJKZyQT7h9bPlUWC3
RODjQReyCITRrdwyrKUGku2FmeVGwn2u2WmDMNABLnpprWPkBdCk96+OmSLN9brZ
fw2vOUgCmYv2hW0hyDHuvYlQA/BThQoADgj8AW6/0Lo7V1W9/8VuHP0gQwCgvzV3
BqOxRznNCRCRxAuAuVztHRcEAJooQK1+iSiunZMYD1WufeXfshc57S/+yeJkegNW
hxwR9pRWVArNYJdDRT+rf2RUe3vpquKNQU/hnEIUHJRQqYHo8gTxvxXNQc7fJYLV
K2HtkrPbP72vwsEKMYhhr0eKCbtLGfls9krjJ6sBgACyP/Vb7hiPwxh6rDZ7ITnE
kYpXBACmWpP8NJTkamEnPCia2ZoOHODANwpUkP43I7jsDmgtobZX9qnrAXw+uNDI
QJEXM6FSbi0LLtZciNlYsafwAPEOMDKpMqAK6IyisNtPvaLd8lH0bPAnWqcyefep
rv0sxxqUEMcM3o7wwgfN83POkDasDbs3pjwPhxvhz6//62zQJ7Q2TXlTUUwgUmVs
ZWFzZSBFbmdpbmVlcmluZyA8bXlzcWwtYnVpbGRAb3NzLm9yYWNsZS5jb20+iGkE
ExECACkCGyMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAIZAQUCUwHUZgUJGmbLywAK
CRCMcY07UHLh9V+DAKCjS1gGwgVI/eut+5L+l2v3ybl+ZgCcD7ZoA341HtoroV3U
6xRD09fUgeq0O015U1FMIFBhY2thZ2Ugc2lnbmluZyBrZXkgKHd3dy5teXNxbC5j
b20pIDxidWlsZEBte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AWzE7zaD5cH9J7yv/6xuZVw411x0h4UqsTcWMu0iM1BzELqX1DY7LwoPEb/O9Rkb
f4fmLe11EzIaCa4PqARXQZc4dhSinMt6K3X4BrRsKTfozBu74F47D8Ilbf5vSYHb
uE5p/1oIDznkg/p8kW+3FxuWrycciqFTcNz215yyX39LXFnlLzKUb/F5GwADBQf+
Lwqqa8CGrRfsOAJxim63CHfty5mUc5rUSnTslGYEIOCR1BeQauyPZbPDsDD9MZ1Z
aSafanFvwFG6Llx9xkU7tzq+vKLoWkm4u5xf3vn55VjnSd1aQ9eQnUcXiL4cnBGo
TbOWI39EcyzgslzBdC++MPjcQTcA7p6JUVsP6oAB3FQWg54tuUo0Ec8bsM8b3Ev4
2LmuQT5NdKHGwHsXTPtl0klk4bQk4OajHsiy1BMahpT27jWjJlMiJc+IWJ0mghkK
Ht926s/ymfdf5HkdQ1cyvsz5tryVI3Fx78XeSYfQvuuwqp2H139pXGEkg0n6KdUO
etdZWhe70YGNPw1yjWJT1IhUBBgRAgAMBQJOdz3tBQkT+wG4ABIHZUdQRwABAQkQ
jHGNO1By4fUUmwCbBYr2+bBEn/L2BOcnw9Z/QFWuhRMAoKVgCFm5fadQ3Afi+UQl
AcOphrnJ
=443I
-----END PGP PUBLIC KEY BLOCK-----

5. 安装

 
        yum install mysql-community-server -y
 
6. 启动
 
        service mysqld start 

7.登录mysql

先停止mysql服务
service mysqld stop
mysqld_safe --skip-grant-tables&

mysql -uroot -p
UPDATE user SET password=PASSWORD("***********") WHERE user='root';

FLUSH PRIVILEGES;

Linux安装mysql过程(转+完善)的更多相关文章

  1. linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题]

    linux安装mysql全纪录[包括yum和rpm安装,编码,远程连接以及大小写问题] 一.查看mysql是否已经安装 使用“whereis mysql”命令来查看mysql安装路径: [root@h ...

  2. 最详细的linux安装php过程

    本文主要和大家分享最详细的linux安装php过程,然后写好了nginx的安装配置,后面就是php的安装和mysql的安装,不过时间有限,而且放篇里也太长,所以都是分开来写,php安装完毕后就是mys ...

  3. linux安装mysql后root无法登录 sql 无法登录

    linux安装mysql后root无法登录 问题:[root@localhost mysql]# mysql -u root -pEnter password: ERROR 1045 (28000): ...

  4. linux安装mysql~~~mysql5.6.12

    Linux安装mysql服务器 准备: MySQL-client-5.6.12-1.rhel5.i386.rpm MySQL-server-5.6.12-1.rhel5.i386.rpm 首先检查环境 ...

  5. linux安装mysql服务分两种安装方法:

    linux安装mysql服务分两种安装方法: ①源码安装,优点是安装包比较小,只有十多M,缺点是安装依赖的库多,安装编译时间长,安装步骤复杂容易出错: ②使用官方编译好的二进制文件安装,优点是安装速度 ...

  6. linux安装MySQL后输入mysql显示 ERROR 2002 (HY000): Can't connect to local MySQL server through socket

    我是小白,大佬勿喷 *** linux安装MySQL后输入mysql显示 ERROR 2002 (HY000): Can't connect to local MySQL server through ...

  7. Linux 安装Mysql(图文教程)

    原文:Linux 安装Mysql(图文教程) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net ...

  8. win10安装mysql过程&&链接过程&&备份和导入数据&&grant命令

    win10安装mysql过程&&链接过程&&备份和导入数据&&grant命令   一 .安装 一开始在mysql官网(https://www.mysql ...

  9. Linux 安装 MySQL 8 数据库(图文详细教程)

    本教程手把手教你如何在 Linux 安装 MySQL 数据库,以 CentOS 7为例. 1. 下载并安装 MySQL 官方的 Yum Repository wget -i -c https://re ...

随机推荐

  1. ubuntu ftp服务

    apt-get install vsftpd apt-get update vi /etc/apt/sources.list vim  /etc/vsftpd.conf service vsftpd ...

  2. springMVC 使用WebApplicationContext获取ApplicationContext对象

    主要用于从application中获取bean 1.applicationContext 在web.xml中使用listener配置 <context-param> <param-n ...

  3. 《mysql从入门到精通》提高

    第一 游标的使用 delimiter $$ DROP PROCEDURE IF EXISTS product_in_sheet_handler; CREATE PROCEDURE product_in ...

  4. Django-website 程序案例系列-4 ORM数据库操作

    数据库表的创建: 使用mysql时注意,在setting.py中的设置: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql' ...

  5. Code First NotMapped

    转载:http://www.cnblogs.com/libingql/p/3352058.html 不需要映射的字段,添加 NotMapped 6.非数据库字段属性 在类中,如果有一些属性不需要映射到 ...

  6. day12 max min zip 用法

    max min ,查看最大值,最小值 基础玩法 l = [1,2,3,4,5] print(max(l)) print(min(l)) 高端玩法 默认字典的取值是key的比较 age_dic={'al ...

  7. Java OOM 常见情况

    Java OOM 常见情况 原文:https://blog.csdn.net/qq_42447950/article/details/81435080 1)什么是OOM?  OOM,全称“Out Of ...

  8. idea 项目打包发布

    clean install -Dmaven.test.skip=true -pl 项目名(maven为准) -am -amd

  9. MT【55】近零点

    [Among the natural enemy of mathematics, the most important thing is that how do we konw     somethi ...

  10. 一种使用emwin库函数导致hardfault的情况

    @2018-08-27 使用函数 WM_SendMessageNoPara(hWin_MainTask, WM_INIT_DIALOG),调试至此处进入hardfault,经查是由于hWin_Main ...