环境准备

  1. mysql下载地址:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
  2. Linux系统版本:centos 7

安装步骤

https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 750 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql # MySQL 5.7.5
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysqld
shell> service mysqld start

测试服务器是否安装成功

到这步服务也起来了。。但是有个问题就是,我没有设置密码和用户啊。这测试服务器可怎么整?

通过启动bin/mysql_safe 来启动并修改密码

1.停掉mysql服务器

[root@DB-Server init.d]# /etc/rc.d/init.d/mysql stop
Shutting down MySQL..[ OK ]

2.启动mysqld_safe 指定 --skip-grant-tables

[root@DB-Server init.d]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

3.登录mysql服务器

[root@DB-Server bin]# ./mysql -u[你的用户名] -p[你的密码]

4.修改mysql root密码

shell>use mysql;
shell>update user set password=PASSWORD('[你的新密码]') where user='root' and host='root' or host='localhost';
shell>flush privileges;

5.设置mysql可以远程访问

shell>user mysql;
shell>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '[你的root密码]' WITH GRANT OPTION;
shell>flush privileges;

6.mysql数据库用户密码已修改,现在重新关闭mysqld服务器,然后重新连接下,服务已经正式启动了,接下来运行一下测试shell命令,看看服务器是否运行正常。

- 使用mysqladmin验证服务器是否正在运行。

shell> bin/mysqladmin version
shell> bin/mysqladmin variables

如果无法连接到服务器,请指定-u root选项以root身份连接。如果您已经为root帐户分配了密码,则还需要在命令行中指定-p,并在出现提示时输入密码。例如:

shell> bin/mysqladmin -u root -p version
Enter password: (enter root password here)

根据您的平台和MySQL版本,mysqladmin版本的输出略有不同,但应与之类似:

shell> bin/mysqladmin version
mysqladmin Ver 14.12 Distrib 5.7.20, for pc-linux-gnu on i686
... Server version 5.7.20
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 14 days 5 hours 5 min 21 sec Threads: 1 Questions: 366 Slow queries: 0
Opens: 0 Flush tables: 1 Open tables: 19
Queries per second avg: 0.000

要查看还有什么可以使用mysqladmin,请使用--help选项调用它。

验证关闭服务器

验证您是否可以关闭服务器(如果root帐户已经有密码,则包括-p选项)

shell> bin/mysqladmin -u root shutdown

验证重新开启服务器

验证您是否可以重新启动服务器。通过使用mysqld_safe或直接调用mysqld来执行此操作。例如:

shell> bin/mysqld_safe --user=mysql &

如果开启失败,请查阅:失败原因

查看存在的数据库

已安装数据库的列表可能有所不同,但始终包含最小的mysql和information_schema.

shell> bin/mysqlshow
+--------------------+
| Databases |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+

如果指定数据库名称,mysqlshow将显示数据库中的表的列表:

shell> bin/mysqlshow mysql
Database: mysql
+---------------------------+
| Tables |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+

执行sql命令

shell> bin/mysql -e "SELECT User, Host, plugin FROM mysql.user" mysql
+------+-----------+-----------------------+
| User | Host | plugin |
+------+-----------+-----------------------+
| root | localhost | mysql_native_password |
+------+-----------+-----------------------+

mysql - MySQL命令行工具,

mysqladmin - 用于管理MySQL服务器的客户端

mysqlshow - 显示数据库,表和列信息。

Linux->Mysql安装调试的更多相关文章

  1. ubuntu linux mysql 安装 基本操作 命令

    mysql --help #如果有信息证明系统已经安装了mysql mysql -V #查看版本号 netstat -tap|grep mysql #检查mysql是否在启动状态 卸载mysql: s ...

  2. linux mysql 安装(rpm)

    linux上安装mysql, 就需要两个文件, xx.client.xx.rpm和 xx.server.xx.rpm 如 MySQL-client-community-5.1.72-1.rhel5.i ...

  3. Linux MySql 安装与配置

    为什么选择MySQL数据库? 毫无疑问,绝大多数的使用linux操作系统的大中小型互联网网站都在使用MySQL作为其后端的数据库存储,从大型的BAT门户,到电商平台,分类门户等无一例都使用MySQL数 ...

  4. linux mysql安装(亲测)

    参考文章:http://blog.csdn.net/superchanon/article/details/8546254/ 1.       运行平台:CentOS 6.7 x86_64 2.    ...

  5. linux Mysql 安装及配置

    1.准备 cmake-3.6.0.tar.gz bison-3.0.4.tar.gz mysql-5.7.13.tar.gz (http://dev.mysql.com/get/Downloads/M ...

  6. Linux MySql安装步骤

    本文将以MySQL 5.5.47为例,以CentOS 6.5为平台,讲述MySQL数据库的安装和设置. 源码包方式安装 1.新建MySql用户和用户组 groupadd mysql useradd - ...

  7. linux mysql 安装

    操作系统 Centos 7.2以上版本 操作系统 centos 7.2以上版本 mysql 版本 mysql-5.7.23-el7-x86_64.tar.gz 1.1 安装准备 1.  创建安装文件存 ...

  8. linux mysql安装问题

    1.rpm -qa | grep mysql   //首先检查是否安装了mysql   2.如果安装了,卸载 rpm -e mysql   3\ 下载地址 http://dev.mysql.com/d ...

  9. linux mysql 安装配置

    1.确认当前linux系统版本,使用以下命令: cat /etc/issue cat /etc/redhat-release 2.下载对应linux系统的mysql安装包. 下载地址:http://d ...

  10. CentOS下Mysql安装调试

    一.安装   yum安装:yum install -y mysql-server mysql mysql-devel 设置自启动:chkconfig mysqld on 启动MySQL:service ...

随机推荐

  1. egg

    简介 阿里的   红色的是项目名字 egg-init --type simple First && cd First  egg-init --type simple Second &a ...

  2. linux下VI模式中上下左右键和回退键出现字母

    1.编辑/etc/vim/vimrc.tiny 由于/etc/vim/vimrc.tiny的拥有者是root用户,所以要在root的权限下对这个文件进行修改.很简单,这个文件里面的倒数第二句话是“se ...

  3. Netflix Hystrix笔记

    maven引入 <dependency> <groupId>com.netflix.hystrix</groupId> <artifactId>hyst ...

  4. 【Lua】Lua + LWT + ExtJS构建目录树

    Lua处理后台逻辑,Lua lwt搭建后台程序,ExtJS根据后台传来的json数据构建目录树. 前台html和ExtJS代码不用多讲,直接上代码: treePanel.html <html&g ...

  5. java多线程开发,Executors、FutureTask、Callable

    java多线程如何应用呢,几乎学java的同学都知道Thread类和Runable接口.继承Thread类或者实现Runable接口,调用thread的start方法即可启动线程. 然后是线程池,就是 ...

  6. C 标准库 - string.h

    C 标准库 - string.h This header file defines several functions to manipulate C strings and arrays. stri ...

  7. Mybatis Dao开发的两种方式(一)

     原始Dao的开发方式: 1.创建数据库配置文件db.properties jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localh ...

  8. [PY3]——heap模块 和 堆排序

    heapify( ) heapify()函数用于将一个序列转化为初始化堆 nums=[16,7,3,20,17,8,-1] print('nums:',nums) show_tree(nums) nu ...

  9. no jpeg in java.library.path;java.lang.NoClassDefFoundError: Could not initialize class sun.awt.image.codec.JPEGImageEncoderImpl

    no jpeg in java.library.path;java.lang.NoClassDefFoundError: Could not initialize class sun.awt.imag ...

  10. The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter.

    The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the assoc ...