mysql在centos上的安装与启动

下载:
[root@luffy etc]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
--2018-03-03 17:59:27--  http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [跟随至新的 URL]
--2018-03-03 17:59:28--  https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm [跟随至新的 URL]
--2018-03-03 17:59:29--  https://repo.mysql.com//mysql-community-release-el7-5.noarch.rpm
正在解析主机 repo.mysql.com (repo.mysql.com)... 23.56.25.233
正在连接 repo.mysql.com (repo.mysql.com)|23.56.25.233|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:6140 (6.0K) [application/x-redhat-package-manager]
正在保存至: “mysql-community-release-el7-5.noarch.rpm”


100%[===============================================================================================>] 6,140       --.-K/s 用时 0s      


2018-03-03 17:59:31 (282 MB/s) - 已保存 “mysql-community-release-el7-5.noarch.rpm” [6140/6140])


安装:
[root@luffy home]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:mysql-community-release-el7-5    ################################# [100%]
[root@luffy home]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
准备中...                          ################################# [100%]
        软件包 mysql-community-release-el7-5.noarch 已经安装
[root@luffy home]# yum install -y mysql-community-server
已加载插件:fastestmirror
mysql-connectors-community                                                                                        | 2.5 kB  00:00:00     
mysql-tools-community                                                                                             | 2.5 kB  00:00:00     
mysql56-community                                                                                                 | 2.5 kB  00:00:00     
(1/3): mysql-connectors-community/x86_64/primary_db                                                               |  18 kB  00:00:00     
(2/3): mysql-tools-community/x86_64/primary_db                                                                    |  38 kB  00:00:01     
(3/3): mysql56-community/x86_64/primary_db                                                                        | 184 kB  00:00:03     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 mysql-community-server.x86_64.0.5.6.39-2.el7 将被 安装
--> 正在处理依赖关系 mysql-community-common(x86-64) = 5.6.39-2.el7,它被软件包 mysql-community-server-5.6.39-2.el7.x86_64 需要
--> 正在处理依赖关系 mysql-community-client(x86-64) >= 5.6.10,它被软件包 mysql-community-server-5.6.39-2.el7.x86_64 需要
--> 正在处理依赖关系 perl(Data::Dumper),它被软件包 mysql-community-server-5.6.39-2.el7.x86_64 需要
--> 正在处理依赖关系 perl(DBI),它被软件包 mysql-community-server-5.6.39-2.el7.x86_64 需要
--> 正在检查事务
---> 软件包 mariadb.x86_64.1.5.5.56-2.el7 将被 取代
---> 软件包 mysql-community-client.x86_64.0.5.6.39-2.el7 将被 舍弃
--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 5.6.10,它被软件包 mysql-community-client-5.6.39-2.el7.x86_64 需要
---> 软件包 mysql-community-common.x86_64.0.5.6.39-2.el7 将被 安装
---> 软件包 perl-DBI.x86_64.0.1.627-4.el7 将被 安装
--> 正在处理依赖关系 perl(RPC::PlServer) >= 0.2001,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
--> 正在处理依赖关系 perl(RPC::PlClient) >= 0.2000,它被软件包 perl-DBI-1.627-4.el7.x86_64 需要
---> 软件包 perl-Data-Dumper.x86_64.0.2.145-3.el7 将被 安装
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.56-2.el7 将被 取代
---> 软件包 mysql-community-libs.x86_64.0.5.6.39-2.el7 将被 舍弃
---> 软件包 perl-PlRPC.noarch.0.0.2020-14.el7 将被 安装
--> 正在处理依赖关系 perl(Net::Daemon) >= 0.13,它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Test),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Net::Daemon::Log),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Zlib),它被软件包 perl-PlRPC-0.2020-14.el7.noarch 需要
--> 正在检查事务
---> 软件包 perl-IO-Compress.noarch.0.2.061-2.el7 将被 安装
--> 正在处理依赖关系 perl(Compress::Raw::Zlib) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
--> 正在处理依赖关系 perl(Compress::Raw::Bzip2) >= 2.061,它被软件包 perl-IO-Compress-2.061-2.el7.noarch 需要
---> 软件包 perl-Net-Daemon.noarch.0.0.48-5.el7 将被 安装
--> 正在检查事务
---> 软件包 perl-Compress-Raw-Bzip2.x86_64.0.2.061-3.el7 将被 安装
---> 软件包 perl-Compress-Raw-Zlib.x86_64.1.2.061-4.el7 将被 安装
--> 解决依赖关系完成


依赖关系解决


=========================================================================================================================================
 Package                                 架构                   版本                             源                                 大小
=========================================================================================================================================
正在安装:
 mysql-community-client                  x86_64                 5.6.39-2.el7                     mysql56-community                  19 M
      替换  mariadb.x86_64 1:5.5.56-2.el7
 mysql-community-libs                    x86_64                 5.6.39-2.el7                     mysql56-community                 2.0 M
      替换  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-server                  x86_64                 5.6.39-2.el7                     mysql56-community                  59 M
为依赖而安装:
 mysql-community-common                  x86_64                 5.6.39-2.el7                     mysql56-community                 257 k
 perl-Compress-Raw-Bzip2                 x86_64                 2.061-3.el7                      base                               32 k
 perl-Compress-Raw-Zlib                  x86_64                 1:2.061-4.el7                    base                               57 k
 perl-DBI                                x86_64                 1.627-4.el7                      base                              802 k
 perl-Data-Dumper                        x86_64                 2.145-3.el7                      base                               47 k
 perl-IO-Compress                        noarch                 2.061-2.el7                      base                              260 k
 perl-Net-Daemon                         noarch                 0.48-5.el7                       base                               51 k
 perl-PlRPC                              noarch                 0.2020-14.el7                    base                               36 k


事务概要
=========================================================================================================================================
安装  3 软件包 (+8 依赖软件包)


总下载量:82 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.39-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
mysql-community-common-5.6.39-2.el7.x86_64.rpm 的公钥尚未安装
(1/11): mysql-community-common-5.6.39-2.el7.x86_64.rpm                                                            | 257 kB  00:00:02     
(2/11): mysql-community-libs-5.6.39-2.el7.x86_64.rpm                                                              | 2.0 MB  00:00:05     
(3/11): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm                                                            |  32 kB  00:00:00     
(4/11): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm                                                             |  57 kB  00:00:00     
(5/11): perl-Data-Dumper-2.145-3.el7.x86_64.rpm                                                                   |  47 kB  00:00:00     
(6/11): perl-Net-Daemon-0.48-5.el7.noarch.rpm                                                                     |  51 kB  00:00:00     
(7/11): perl-PlRPC-0.2020-14.el7.noarch.rpm                                                                       |  36 kB  00:00:00     
(8/11): perl-DBI-1.627-4.el7.x86_64.rpm                                                                           | 802 kB  00:00:01     
(9/11): perl-IO-Compress-2.061-2.el7.noarch.rpm                                                                   | 260 kB  00:00:00     
(10/11): mysql-community-client-5.6.39-2.el7.x86_64.rpm                                                           |  19 MB  00:00:42     
(11/11): mysql-community-server-5.6.39-2.el7.x86_64.rpm                                                           |  59 MB  00:13:22     
-----------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                     104 kB/s |  82 MB  00:13:30     
从 file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥
导入 GPG key 0x5072E1F5:
 用户ID     : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
 指纹       : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 软件包     : mysql-community-release-el7-5.noarch (installed)
 来自       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                 1/13
  正在安装    : mysql-community-common-5.6.39-2.el7.x86_64                                                                          2/13
  正在安装    : mysql-community-libs-5.6.39-2.el7.x86_64                                                                            3/13
  正在安装    : mysql-community-client-5.6.39-2.el7.x86_64                                                                          4/13
  正在安装    : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                         5/13
  正在安装    : perl-Net-Daemon-0.48-5.el7.noarch                                                                                   6/13
  正在安装    : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                          7/13
  正在安装    : perl-IO-Compress-2.061-2.el7.noarch                                                                                 8/13
  正在安装    : perl-PlRPC-0.2020-14.el7.noarch                                                                                     9/13
  正在安装    : perl-DBI-1.627-4.el7.x86_64                                                                                        10/13
  正在安装    : mysql-community-server-5.6.39-2.el7.x86_64                                                                         11/13
  正在删除    : 1:mariadb-5.5.56-2.el7.x86_64                                                                                      12/13
  正在删除    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                 13/13
  验证中      : mysql-community-server-5.6.39-2.el7.x86_64                                                                          1/13
  验证中      : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                          2/13
  验证中      : perl-Net-Daemon-0.48-5.el7.noarch                                                                                   3/13
  验证中      : mysql-community-common-5.6.39-2.el7.x86_64                                                                          4/13
  验证中      : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                 5/13
  验证中      : mysql-community-libs-5.6.39-2.el7.x86_64                                                                            6/13
  验证中      : perl-PlRPC-0.2020-14.el7.noarch                                                                                     7/13
  验证中      : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                         8/13
  验证中      : perl-DBI-1.627-4.el7.x86_64                                                                                         9/13
  验证中      : perl-IO-Compress-2.061-2.el7.noarch                                                                                10/13
  验证中      : mysql-community-client-5.6.39-2.el7.x86_64                                                                         11/13
  验证中      : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                                                 12/13
  验证中      : 1:mariadb-5.5.56-2.el7.x86_64                                                                                      13/13


已安装:
  mysql-community-client.x86_64 0:5.6.39-2.el7  mysql-community-libs.x86_64 0:5.6.39-2.el7  mysql-community-server.x86_64 0:5.6.39-2.el7


作为依赖被安装:
  mysql-community-common.x86_64 0:5.6.39-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
  perl-DBI.x86_64 0:1.627-4.el7                perl-Data-Dumper.x86_64 0:2.145-3.el7        perl-IO-Compress.noarch 0:2.061-2.el7      
  perl-Net-Daemon.noarch 0:0.48-5.el7          perl-PlRPC.noarch 0:0.2020-14.el7           


替代:
  mariadb.x86_64 1:5.5.56-2.el7                                    mariadb-libs.x86_64 1:5.5.56-2.el7                                   


完毕!
[root@luffy home]#

 


列出当前rpm包的文件列表及安装位置
[root@luffy home]# rpm -ql mysql-community-server
/etc/logrotate.d/mysql
/etc/my.cnf
/etc/my.cnf.d
/usr/bin/innochecksum
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql-systemd-start


查看是否安装mysql服务
[root@luffy etc]# systemctl list-unit-files | grep mysqld
mysqld.service                                enabled


查看配置文件
[root@luffy etc]# cat -n /etc/my.cnf


启动mysql服务
[root@luffy etc]# systemctl start mysqld


查看mysql的启动状态
[root@luffy etc]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2018-03-03 19:14:48 CST; 4s ago
  Process: 2490 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 2427 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 2489 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─2489 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─2656 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/m...


3月 03 19:14:46 luffy mysql-systemd-start[2427]: Support MySQL by buying support/licenses at http://shop.mysql.com
3月 03 19:14:46 luffy mysql-systemd-start[2427]: Note: new default config file not created.
3月 03 19:14:46 luffy mysql-systemd-start[2427]: Please make sure your config file is current
3月 03 19:14:46 luffy mysql-systemd-start[2427]: WARNING: Default config file /etc/my.cnf exists on the system
3月 03 19:14:46 luffy mysql-systemd-start[2427]: This file will be read by default by the MySQL server
3月 03 19:14:46 luffy mysql-systemd-start[2427]: If you do not want to use this, either remove it, or use the
3月 03 19:14:46 luffy mysql-systemd-start[2427]: --defaults-file argument to mysqld_safe when starting the server
3月 03 19:14:46 luffy mysqld_safe[2489]: 180303 19:14:46 mysqld_safe Logging to '/var/log/mysqld.log'.
3月 03 19:14:46 luffy mysqld_safe[2489]: 180303 19:14:46 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3月 03 19:14:48 luffy systemd[1]: Started MySQL Community Server.
[root@luffy etc]#


查看mysql服务的相关进程
[root@luffy ~]# ps -ef|grep mysql
mysql     2489     1  0 19:14 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     2656  2489  0 19:14 ?        00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      2697  1256  0 19:24 pts/0    00:00:00 grep --color=auto mysql
[root@luffy ~]#

 


mysql启动后的默认数据目录
[root@luffy ~]# ls -lh /var/lib/mysql
总用量 109M
-rw-rw----. 1 mysql mysql   56 3月   3 19:14 auto.cnf
-rw-rw----. 1 mysql mysql  12M 3月   3 19:14 ibdata1
-rw-rw----. 1 mysql mysql  48M 3月   3 19:14 ib_logfile0
-rw-rw----. 1 mysql mysql  48M 3月   3 19:14 ib_logfile1
drwx------. 2 mysql mysql 4.0K 3月   3 19:14 mysql
srwxrwxrwx. 1 mysql mysql    0 3月   3 19:14 mysql.sock
drwx------. 2 mysql mysql 4.0K 3月   3 19:14 performance_schema
[root@luffy ~]#


登录测试
[root@luffy ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.39 MySQL Community Server (GPL)


Copyright (c) 2000, 2018, 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>
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.6.39    |
+-----------+
1 row in set (0.00 sec)


mysql>


初始化用户为root,密码为空。
---------------------  

===============================================================================================

配置指定其它的数据目录,如将数据目录设定为/data/mysql_data_3307,端口为3307
[root@luffy ~]# mkdir -p /data/mysql_data_3307
[root@luffy ~]# chown -R mysql.mysql /data/mysql_data_3307
[root@luffy ~]# mysql_install_db --datadir=/data/mysql_data_3307 --user=mysql
Installing MySQL system tables...2018-03-03 19:36:42 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-03 19:36:42 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-03-03 19:36:42 0 [Note] /usr/sbin/mysqld (mysqld 5.6.39) starting as process 2708 ...
2018-03-03 19:36:42 2708 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-03 19:36:42 2708 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-03 19:36:42 2708 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-03 19:36:42 2708 [Note] InnoDB: Memory barrier is not used
2018-03-03 19:36:42 2708 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-03 19:36:42 2708 [Note] InnoDB: Using Linux native AIO
2018-03-03 19:36:42 2708 [Note] InnoDB: Using CPU crc32 instructions
2018-03-03 19:36:42 2708 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-03 19:36:42 2708 [Note] InnoDB: Completed initialization of buffer pool
2018-03-03 19:36:42 2708 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-03-03 19:36:42 2708 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-03-03 19:36:42 2708 [Note] InnoDB: Database physically writes the file full: wait...
2018-03-03 19:36:42 2708 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-03-03 19:36:43 2708 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-03-03 19:36:44 2708 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-03-03 19:36:44 2708 [Warning] InnoDB: New log files created, LSN=45781
2018-03-03 19:36:44 2708 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-03-03 19:36:44 2708 [Note] InnoDB: Doublewrite buffer created
2018-03-03 19:36:44 2708 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-03 19:36:44 2708 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-03 19:36:44 2708 [Note] InnoDB: Foreign key constraint system tables created
2018-03-03 19:36:44 2708 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-03-03 19:36:44 2708 [Note] InnoDB: Tablespace and datafile system tables created.
2018-03-03 19:36:44 2708 [Note] InnoDB: Waiting for purge to start
2018-03-03 19:36:44 2708 [Note] InnoDB: 5.6.39 started; log sequence number 0
2018-03-03 19:36:44 2708 [Note] Binlog end
2018-03-03 19:36:44 2708 [Note] InnoDB: FTS optimize thread exiting.
2018-03-03 19:36:44 2708 [Note] InnoDB: Starting shutdown...
2018-03-03 19:36:46 2708 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK


Filling help tables...2018-03-03 19:36:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-03 19:36:46 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-03-03 19:36:46 0 [Note] /usr/sbin/mysqld (mysqld 5.6.39) starting as process 2730 ...
2018-03-03 19:36:46 2730 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-03-03 19:36:46 2730 [Note] InnoDB: The InnoDB memory heap is disabled
2018-03-03 19:36:46 2730 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-03-03 19:36:46 2730 [Note] InnoDB: Memory barrier is not used
2018-03-03 19:36:46 2730 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-03-03 19:36:46 2730 [Note] InnoDB: Using Linux native AIO
2018-03-03 19:36:46 2730 [Note] InnoDB: Using CPU crc32 instructions
2018-03-03 19:36:46 2730 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-03-03 19:36:46 2730 [Note] InnoDB: Completed initialization of buffer pool
2018-03-03 19:36:46 2730 [Note] InnoDB: Highest supported file format is Barracuda.
2018-03-03 19:36:46 2730 [Note] InnoDB: 128 rollback segment(s) are active.
2018-03-03 19:36:46 2730 [Note] InnoDB: Waiting for purge to start
2018-03-03 19:36:46 2730 [Note] InnoDB: 5.6.39 started; log sequence number 1625977
2018-03-03 19:36:46 2730 [Note] Binlog end
2018-03-03 19:36:46 2730 [Note] InnoDB: FTS optimize thread exiting.
2018-03-03 19:36:46 2730 [Note] InnoDB: Starting shutdown...
2018-03-03 19:36:48 2730 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK


To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:


  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h luffy password 'new-password'


Alternatively you can run:


  /usr/bin/mysql_secure_installation


which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.


See the manual for more instructions.


You can start the MySQL daemon with:


  cd /usr ; /usr/bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl


  cd mysql-test ; perl mysql-test-run.pl


Please report any problems at http://bugs.mysql.com/


The latest information about MySQL is available on the web at


  http://www.mysql.com


Support MySQL by buying support/licenses at http://shop.mysql.com


New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings


WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server


[root@luffy ~]#


查看系统表相关的数据库
[root@luffy ~]# ls -lh /data/mysql_data_3307/
总用量 109M
-rw-rw----. 1 mysql mysql  12M 3月   3 19:36 ibdata1
-rw-rw----. 1 mysql mysql  48M 3月   3 19:36 ib_logfile0
-rw-rw----. 1 mysql mysql  48M 3月   3 19:36 ib_logfile1
drwx------. 2 mysql mysql 4.0K 3月   3 19:36 mysql
drwx------. 2 mysql mysql 4.0K 3月   3 19:36 performance_schema
[root@luffy ~]#
[root@luffy ~]# mysqld_safe --datadir=/data/mysql_data_3307/ --socket=/data/mysql_data_3307/mysql.sock --user=mysql --bind-address=192.168.229.151 &
[1] 2756
[root@luffy ~]# 180303 19:42:33 mysqld_safe Logging to '/var/log/mysqld.log'.
180303 19:42:33 mysqld_safe A mysqld process already exists
^C
[1]+  退出 1                mysqld_safe --datadir=/data/mysql_data_3307/ --socket=/data/mysql_data_3307/mysql.sock --user=mysql --bind-address=192.168.229.151


本例中因为默认的数据库开启着,导致开启指定目录的数据库时,mysqlld进程提示已存在。
[root@luffy ~]#
[root@luffy ~]#
[root@luffy ~]# ps -ef|grep mysql
mysql     2489     1  0 19:14 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql     2656  2489  0 19:14 ?        00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root      2940  1256  0 19:43 pts/0    00:00:00 grep --color=auto mysql
[root@luffy ~]#


[root@luffy ~]# ps -ef|grep mysqld_safe
mysql     2489     1  0 19:14 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
root      2942  1256  0 19:44 pts/0    00:00:00 grep --color=auto mysqld_safe
[root@luffy ~]#
[root@luffy ~]# netstat -plnt|grep 3307
[root@luffy ~]#
[root@luffy ~]#
[root@luffy ~]# mysql -S /data/mysql_data_3307/mysql.sock -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/mysql_data_3307/mysql.sock' (2)
[root@luffy ~]#

 

 

 

 

 

 

 

 
---------------------  
作者:siwluxuefeng  
来源:CSDN  
原文:https://blog.csdn.net/Linzhongyilisha/article/details/79432468  
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值