Linux5下安装MySQL过程记录

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

1)下载:

在mysql的网站上,下载  mysql-5.6.13-linux-glibc2.5-x86_64.tar.gz 

比如拷贝到 /soft/mysql5/ 目录下。

2)解压:

[root@server local]#cd /usr/local
[root@server local]#tar zxvf /soft/mysql5/mysql-5.6.13-linux-glibc2.5-x86_64.tar.gz

3)建立软链接:

[root@server local]#ln -s mysql-5.6.13-linux-glibc2.5-x86_64 mysql

  查看:  

       [root@server local]# ls -lrt mysql
       lrwxrwxrwx 1 root root 36 9月 12 13:22 mysql -> ./mysql-5.6.13-linux-glibc2.5-x86_64
       [root@server local]#

4)建立mysql相关的用户和组:

[root@server local]#groupadd mysql
[root@server local]#useradd -r -g mysql mysql

 

5)生成数据库:

[root@server local]# cd mysql
[root@server local]# chown -R mysql .
[root@server local]#chgrp -R mysql .
[root@server local]# scripts/mysql_install_db --user=mysql
[root@server local]# chown -R root .
[root@server local]# chown -R mysql data

 

6)拷贝必要的文件(此为可选步骤):

[root@server local]#cp support-files/mysql.server /etc/init.d/mysql.server

 

7)启动数据库:

[root@server local]bin/mysqld_safe --user=mysql &

 

8)访问数据库:

[root@server ~]# mysql --user=mysql 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)

mysql> quit
Bye
[root@server ~]#

 

9)关闭数据库时,发现无法关闭数据库,于是强制关闭进程,然后退出。

10)设置权限:

重新启动数据库(带 --skip-grant-tables参数):

[root@server ~]# mysqld_safe --skip-grant-tables &
[1] 3140
[root@server ~]# 130912 14:49:51 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 14:49:51 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

设置root用户的口令(被要求Enter password的时候,直接按回车键就过去了):

[root@server ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password("abcdef") where user='root' and host='localhost';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[root@server ~]#

为了验证是否可以正常关闭,再次重新启动来看一下:

[root@server ~]# mysqld_safe --skip-grant-tables
130912 14:57:36 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 14:57:36 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

[root@server ~]#

然后运行:

[root@server ~]# mysqladmin -uroot shutdown
[root@server ~]#

 成功关闭。

下一次,完全正常启动,看能否关闭:

[root@server ~]# mysqld_safe
130912 15:01:26 mysqld_safe Logging to '/usr/local/mysql/data/server.gao.err'.
130912 15:01:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

 

[root@server ~]# mysqladmin -uroot -p shutdown
Enter password: 
[root@server ~]#

关闭成功了。 








本文转自健哥的数据花园博客园博客,原文链接:http://www.cnblogs.com/gaojian/p/3317000.html,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
10天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
61 0
|
2天前
|
存储 关系型数据库 MySQL
Linux | MySQL基础
Linux | MySQL基础
|
3天前
|
关系型数据库 MySQL Linux
Linux联网安装MySQL Server
Linux联网安装MySQL Server
13 0
|
3天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
33 2
|
7天前
|
关系型数据库 MySQL 数据库
Docker安装MySQL
Docker安装MySQL
14 1
|
7天前
|
关系型数据库 MySQL 数据安全/隐私保护
MySQL 安装及连接
MySQL 安装及连接
25 0
|
6月前
|
Java 关系型数据库 MySQL
【Linux环境配置】Linux系统安装jdk1.8操作步骤
【Linux环境配置】Linux系统安装jdk1.8操作步骤
234 0
|
存储 Linux 数据安全/隐私保护
linux系统安装步骤
linux系统安装步骤
251 0
linux系统安装步骤
|
安全 关系型数据库 MySQL
Linux系统安装MySql步骤及截屏
原文出自【听云技术博客】:http://blog.tingyun.com/web/article/detail/1255 如下是我工作中的记录,介绍的是linux系统下使用官方编译好的二进制文件进行安装MySql的安装过程和安装截屏,这种安装方式速度快,安装步骤简单! 需要的朋友可以按照如下
4858 0