数据库二进制包下载

社区版:
https://dev.mysql.com/downloads/mysql/

image.png
image.png

新建 数据组和数据库启动用户

  1. groupadd -g 401 mysql
  2. useradd -g 401 -u 401 mysql

设置环境变量

  1. export PATH=/app/mysql/bin:$PATH

  1. [mysql@riyimei ~]$ ls -la
  2. total 20
  3. drwx------ 2 mysql mysql 99 Feb 21 10:22 .
  4. drwxr-xr-x. 7 root root 135 Feb 21 10:17 ..
  5. -rw------- 1 mysql mysql 117 Feb 21 10:19 .bash_history
  6. -rw-r--r-- 1 mysql mysql 18 Aug 8 2019 .bash_logout
  7. -rw-r--r-- 1 mysql mysql 214 Feb 21 10:21 .bash_profile
  8. -rw-r--r-- 1 mysql mysql 231 Aug 8 2019 .bashrc
  9. -rw------- 1 mysql mysql 648 Feb 21 10:22 .viminfo
  10. [mysql@riyimei ~]$ cat .bash_profile
  11. # .bash_profile
  12. # Get the aliases and functions
  13. if [ -f ~/.bashrc ]; then
  14. . ~/.bashrc
  15. fi
  16. # User specific environment and startup programs
  17. PATH=$PATH:$HOME/.local/bin:$HOME/bin
  18. export PATH=/app/mysql/bin:$PATH
  19. [mysql@riyimei ~]$ . ./.bash_profile

设置文件打开数

建数据库数据存放目录

  1. mkdir -p /data/mysql/3306/{data,redo,binlog,tmp,logs}
  2. chown -R mysql:mysql /data
  3. chmod -R 755 /data
  1. [root@riyimei 3306]# ll
  2. total 0
  3. drwxr-xr-x 2 mysql mysql 6 Feb 21 10:08 binlog
  4. drwxr-xr-x 2 mysql mysql 6 Feb 21 10:08 data
  5. drwxr-xr-x 2 mysql mysql 6 Feb 21 10:08 logs
  6. drwxr-xr-x 2 mysql mysql 6 Feb 21 10:08 redo
  7. drwxr-xr-x 2 mysql mysql 6 Feb 21 10:08 tmp
  8. [root@riyimei 3306]#

拷贝数据库二进制文件到指定部署目录

  1. [root@riyimei ~]# mkdir /app
  2. [root@riyimei ~]# cd /app/
  3. [root@riyimei app]# ll
  4. total 646212
  5. -rw-r--r-- 1 root root 661718255 Feb 21 10:02 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
  6. [root@riyimei app]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
  7. [root@riyimei app]# ls
  8. mysql-5.7.33-linux-glibc2.12-x86_64 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
  9. [root@riyimei app]# ln -s /app/mysql-5.7.33-linux-glibc2.12-x86_64 /app/mysql
  10. [root@riyimei app]# ls
  11. mysql mysql-5.7.33-linux-glibc2.12-x86_64 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
  12. [root@riyimei app]# ll
  13. total 646212
  14. lrwxrwxrwx 1 root root 40 Feb 21 10:03 mysql -> /app/mysql-5.7.33-linux-glibc2.12-x86_64
  15. drwxr-x--- 9 root root 129 Feb 21 10:03 mysql-5.7.33-linux-glibc2.12-x86_64
  16. -rw-r--r-- 1 root root 661718255 Feb 21 10:02 mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
  17. [root@riyimei app]# chown -R mysql:mysql /app
  18. [root@riyimei app]#

检查依赖库 libaio

  1. [root@riyimei app]# rpm -qa libaio
  2. libaio-0.3.109-13.el7.x86_64
  3. [root@riyimei app]#

添加自定义配置文件 my.cnf

  1. [root@riyimei 3306]# ll /data/mysql/3306/my.cnf
  2. -rw-r----- 1 root root 937 Feb 21 10:11 /data/mysql/3306/my.cnf
  3. [root@riyimei 3306]#
  1. [root@riyimei 3306]# cat my.cnf
  2. [client]
  3. default-character-set = utf8
  4. port = 3306
  5. socket = /data/mysql/3306/tmp/mysql.sock
  6. [mysqld]
  7. port = 3306
  8. character_set_server = utf8
  9. server-id = 1
  10. socket = /data/mysql/3306/tmp/mysql.sock
  11. basedir = /app/mysql
  12. datadir = /data/mysql/3306/data
  13. tmpdir = /data/mysql/3306/tmp
  14. log-error = /data/mysql/3306/logs/alert_3306.log
  15. pid-file = /data/mysql/3306/tmp/mysql.pid
  16. log-bin = /data/mysql/3306/binlog/mysql-bin
  17. slow_query_log_file = /data/mysql/3306/logs/slow.log
  18. default-storage-engine = INNODB
  19. innodb_data_file_path = ibdata1:2G:autoextend
  20. innodb_log_group_home_dir = /data/mysql/3306/redo
  21. innodb_file_per_table = 1
  22. [root@riyimei 3306]#

初始化数据库

  1. [mysql@riyimei ~]$ mysqld --defaults-file=/data/mysql/3306/my.cnf --initialize
  2. [mysql@riyimei ~]$ ll /data/mysql/3306/data/
  3. total 2097220
  4. -rw-r----- 1 mysql mysql 56 Feb 21 10:24 auto.cnf
  5. -rw------- 1 mysql mysql 1676 Feb 21 10:24 ca-key.pem
  6. -rw-r--r-- 1 mysql mysql 1112 Feb 21 10:24 ca.pem
  7. -rw-r--r-- 1 mysql mysql 1112 Feb 21 10:24 client-cert.pem
  8. -rw------- 1 mysql mysql 1676 Feb 21 10:24 client-key.pem
  9. -rw-r----- 1 mysql mysql 436 Feb 21 10:24 ib_buffer_pool
  10. -rw-r----- 1 mysql mysql 2147483648 Feb 21 10:24 ibdata1
  11. drwxr-x--- 2 mysql mysql 4096 Feb 21 10:24 mysql
  12. drwxr-x--- 2 mysql mysql 8192 Feb 21 10:24 performance_schema
  13. -rw------- 1 mysql mysql 1676 Feb 21 10:24 private_key.pem
  14. -rw-r--r-- 1 mysql mysql 452 Feb 21 10:24 public_key.pem
  15. -rw-r--r-- 1 mysql mysql 1112 Feb 21 10:24 server-cert.pem
  16. -rw------- 1 mysql mysql 1676 Feb 21 10:24 server-key.pem
  17. drwxr-x--- 2 mysql mysql 8192 Feb 21 10:24 sys
  18. [mysql@riyimei ~]$

查看初始化日志和临时密码

  1. [mysql@riyimei ~]$ tail -n 100 /data/mysql/3306/logs/alert_3306.log
  2. 2021-02-21T02:24:41.718374Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000
  4. 2021-02-21T02:24:42.821456Z 0 [Warning] InnoDB: New log files created, LSN=45791
  5. 2021-02-21T02:24:42.855140Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  6. 2021-02-21T02:24:42.880637Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: f4eff0a2-73eb-11eb-8080-000c290b2539.
  7. 2021-02-21T02:24:42.881010Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  8. 2021-02-21T02:24:43.236334Z 0 [Warning] CA certificate ca.pem is self signed.
  9. 2021-02-21T02:24:43.478305Z 1 [Note] A temporary password is generated for root@localhost: 6NdBc--q3jIg
  10. [mysql@riyimei ~]$

启动数据库

  1. [mysql@riyimei ~]$ mysqld_safe --defaults-file=/data/mysql/3306/my.cnf &
  2. [1] 19089
  3. [mysql@riyimei ~]$ 2021-02-21T02:32:44.036416Z mysqld_safe Logging to '/data/mysql/3306/logs/alert_3306.log'.
  4. 2021-02-21T02:32:44.078430Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/3306/data
  5. [mysql@riyimei ~]$

查看数据库端口

  1. [mysql@riyimei ~]$ netstat -lntup
  2. (Not all processes could be identified, non-owned process info
  3. will not be shown, you would have to be root to see it all.)
  4. Active Internet connections (only servers)
  5. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  6. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
  7. tcp6 0 0 :::3306 :::* LISTEN 19338/mysqld
  8. tcp6 0 0 :::22 :::* LISTEN -
  9. [mysql@riyimei ~]$

启动日志

  1. 2021-02-21T02:32:44.036416Z mysqld_safe Logging to '/data/mysql/3306/logs/alert_3306.log'.
  2. 2021-02-21T02:32:44.078430Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/3306/data
  3. 2021-02-21T02:32:44.332944Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  4. 2021-02-21T02:32:44.333041Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  5. 2021-02-21T02:32:44.333062Z 0 [Note] /app/mysql/bin/mysqld (mysqld 5.7.33-log) starting as process 19338 ...
  6. 2021-02-21T02:32:44.337205Z 0 [Note] InnoDB: PUNCH HOLE support available
  7. 2021-02-21T02:32:44.337236Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  8. 2021-02-21T02:32:44.337241Z 0 [Note] InnoDB: Uses event mutexes
  9. 2021-02-21T02:32:44.337243Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
  10. 2021-02-21T02:32:44.337245Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  11. 2021-02-21T02:32:44.337249Z 0 [Note] InnoDB: Using Linux native AIO
  12. 2021-02-21T02:32:44.337409Z 0 [Note] InnoDB: Number of pools: 1
  13. 2021-02-21T02:32:44.337496Z 0 [Note] InnoDB: Using CPU crc32 instructions
  14. 2021-02-21T02:32:44.338323Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  15. 2021-02-21T02:32:44.343291Z 0 [Note] InnoDB: Completed initialization of buffer pool
  16. 2021-02-21T02:32:44.345147Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  17. 2021-02-21T02:32:44.374764Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  18. 2021-02-21T02:32:44.398600Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  19. 2021-02-21T02:32:44.398665Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  20. 2021-02-21T02:32:44.413876Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  21. 2021-02-21T02:32:44.414516Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  22. 2021-02-21T02:32:44.414544Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  23. 2021-02-21T02:32:44.414799Z 0 [Note] InnoDB: Waiting for purge to start
  24. 2021-02-21T02:32:44.468259Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 2746832
  25. 2021-02-21T02:32:44.469474Z 0 [Note] InnoDB: Loading buffer pool(s) from /data/mysql/3306/data/ib_buffer_pool
  26. 2021-02-21T02:32:44.471023Z 0 [Note] Plugin 'FEDERATED' is disabled.
  27. 2021-02-21T02:32:44.474944Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210221 10:32:44
  28. 2021-02-21T02:32:44.501475Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  29. 2021-02-21T02:32:44.501630Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
  30. 2021-02-21T02:32:44.504096Z 0 [Warning] CA certificate ca.pem is self signed.
  31. 2021-02-21T02:32:44.504277Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
  32. 2021-02-21T02:32:44.504662Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
  33. 2021-02-21T02:32:44.504857Z 0 [Note] IPv6 is available.
  34. 2021-02-21T02:32:44.504881Z 0 [Note] - '::' resolves to '::';
  35. 2021-02-21T02:32:44.504918Z 0 [Note] Server socket created on IP: '::'.
  36. 2021-02-21T02:32:44.512936Z 0 [Note] Failed to start slave threads for channel ''
  37. 2021-02-21T02:32:44.521181Z 0 [Note] Event Scheduler: Loaded 0 events
  38. 2021-02-21T02:32:44.521741Z 0 [Note] /app/mysql/bin/mysqld: ready for connections.
  39. Version: '5.7.33-log' socket: '/data/mysql/3306/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)

登陆数据库 拷贝一份配置文件 并修改配置文件 临时登陆密码查看日志

  1. [mysql@riyimei ~]$ cp /data/mysql/3306/my.cnf /home/mysql/.my.cnf
  2. [mysql@riyimei ~]$
  3. [mysql@riyimei ~]$ ls -la /home/mysql/
  4. total 24
  5. drwx------ 2 mysql mysql 114 Feb 21 10:35 .
  6. drwxr-xr-x. 7 root root 135 Feb 21 10:17 ..
  7. -rw------- 1 mysql mysql 679 Feb 21 10:32 .bash_history
  8. -rw-r--r-- 1 mysql mysql 18 Aug 8 2019 .bash_logout
  9. -rw-r--r-- 1 mysql mysql 214 Feb 21 10:21 .bash_profile
  10. -rw-r--r-- 1 mysql mysql 231 Aug 8 2019 .bashrc
  11. -rw-r----- 1 mysql mysql 937 Feb 21 10:35 .my.cnf
  12. -rw------- 1 mysql mysql 648 Feb 21 10:22 .viminfo
  13. [mysql@riyimei ~]$
  1. [mysql@riyimei ~]$ mysql -uroot -hlocalhost -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 4
  5. Server version: 5.7.33-log
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> show databases;
  12. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  13. mysql> set password='123456';
  14. Query OK, 0 rows affected (0.01 sec)
  15. mysql> flush privileges;
  16. Query OK, 0 rows affected (0.00 sec)
  17. mysql> show databases;
  18. +--------------------+
  19. | Database |
  20. +--------------------+
  21. | information_schema |
  22. | mysql |
  23. | performance_schema |
  24. | sys |
  25. +--------------------+
  26. 4 rows in set (0.00 sec)
  27. mysql>

停止数据库

  1. [mysql@riyimei ~]$ mysqladmin -uroot shutdown -p
  2. Enter password:
  3. [mysql@riyimei ~]$ 2021-02-21T02:46:15.388746Z mysqld_safe mysqld from pid file /data/mysql/3306/tmp/mysql.pid ended
  4. [1]+ Done mysqld_safe --defaults-file=/data/mysql/3306/my.cnf
  5. [mysql@riyimei ~]$
  1. 2021-02-21T02:46:12.906897Z 0 [Note] Giving 0 client threads a chance to die gracefully
  2. 2021-02-21T02:46:12.906926Z 0 [Note] Shutting down slave threads
  3. 2021-02-21T02:46:12.906934Z 0 [Note] Forcefully disconnecting 0 remaining clients
  4. 2021-02-21T02:46:12.906940Z 0 [Note] Event Scheduler: Purging the queue. 0 events
  5. 2021-02-21T02:46:12.907045Z 0 [Note] Binlog end
  6. 2021-02-21T02:46:12.908580Z 0 [Note] Shutting down plugin 'ngram'
  7. 2021-02-21T02:46:12.908601Z 0 [Note] Shutting down plugin 'partition'
  8. 2021-02-21T02:46:12.908605Z 0 [Note] Shutting down plugin 'BLACKHOLE'
  9. 2021-02-21T02:46:12.908608Z 0 [Note] Shutting down plugin 'ARCHIVE'
  10. 2021-02-21T02:46:12.908609Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
  11. 2021-02-21T02:46:12.908642Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
  12. 2021-02-21T02:46:12.908646Z 0 [Note] Shutting down plugin 'MyISAM'
  13. 2021-02-21T02:46:12.908651Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
  14. 2021-02-21T02:46:12.908653Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
  15. 2021-02-21T02:46:12.908672Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
  16. 2021-02-21T02:46:12.908832Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
  17. 2021-02-21T02:46:12.908913Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
  18. 2021-02-21T02:46:12.908964Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
  19. 2021-02-21T02:46:12.909088Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
  20. 2021-02-21T02:46:12.909235Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
  21. 2021-02-21T02:46:12.909265Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
  22. 2021-02-21T02:46:12.909400Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
  23. 2021-02-21T02:46:12.909491Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
  24. 2021-02-21T02:46:12.909544Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
  25. 2021-02-21T02:46:12.909671Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
  26. 2021-02-21T02:46:12.909752Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
  27. 2021-02-21T02:46:12.909784Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
  28. 2021-02-21T02:46:12.909854Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
  29. 2021-02-21T02:46:12.909914Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
  30. 2021-02-21T02:46:12.909916Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
  31. 2021-02-21T02:46:12.909918Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
  32. 2021-02-21T02:46:12.909919Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
  33. 2021-02-21T02:46:12.909920Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
  34. 2021-02-21T02:46:12.909923Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
  35. 2021-02-21T02:46:12.909935Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
  36. 2021-02-21T02:46:12.909972Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
  37. 2021-02-21T02:46:12.909990Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
  38. 2021-02-21T02:46:12.910134Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
  39. 2021-02-21T02:46:12.910139Z 0 [Note] Shutting down plugin 'INNODB_CMP'
  40. 2021-02-21T02:46:12.910140Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
  41. 2021-02-21T02:46:12.910142Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
  42. 2021-02-21T02:46:12.910143Z 0 [Note] Shutting down plugin 'INNODB_TRX'
  43. 2021-02-21T02:46:12.910145Z 0 [Note] Shutting down plugin 'InnoDB'
  44. 2021-02-21T02:46:12.910280Z 0 [Note] InnoDB: FTS optimize thread exiting.
  45. 2021-02-21T02:46:12.910475Z 0 [Note] InnoDB: Starting shutdown...
  46. 2021-02-21T02:46:13.010929Z 0 [Note] InnoDB: Dumping buffer pool(s) to /data/mysql/3306/data/ib_buffer_pool
  47. 2021-02-21T02:46:13.011354Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 210221 10:46:13
  48. 2021-02-21T02:46:14.756073Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2746860
  49. 2021-02-21T02:46:14.757577Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
  50. 2021-02-21T02:46:14.757603Z 0 [Note] Shutting down plugin 'MEMORY'
  51. 2021-02-21T02:46:14.757608Z 0 [Note] Shutting down plugin 'CSV'
  52. 2021-02-21T02:46:14.757630Z 0 [Note] Shutting down plugin 'sha256_password'
  53. 2021-02-21T02:46:14.757634Z 0 [Note] Shutting down plugin 'mysql_native_password'
  54. 2021-02-21T02:46:14.757727Z 0 [Note] Shutting down plugin 'binlog'
  55. 2021-02-21T02:46:14.758076Z 0 [Note] /app/mysql/bin/mysqld: Shutdown complete
  56. 2021-02-21T02:46:15.388746Z mysqld_safe mysqld from pid file /data/mysql/3306/tmp/mysql.pid ended

设置启动脚本

拷贝

  1. [mysql@riyimei ~]$ cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
  1. # Set some defaults
  2. mysqld_pid_file_path=/data/mysql/3306/tmp/mysql.pid
  3. if test -z "$basedir"
  4. then
  5. basedir=/app/mysql
  6. bindir=/app/mysql/bin
  7. if test -z "$datadir"
  8. then
  9. datadir=/data/mysql/data
  10. fi
  11. sbindir=/app/mysql/bin
  12. libexecdir=/app/mysql/bin
  1. [mysql@riyimei ~]$ /etc/init.d/mysqld start
  2. Starting MySQL. SUCCESS!
  3. [mysql@riyimei ~]$ /etc/init.d/mysqld stop
  4. Shutting down MySQL.. SUCCESS!
  5. [mysql@riyimei ~]$ netstat -lntup
  6. (No info could be read for "-p": geteuid()=401 but you should be root.)
  7. Active Internet connections (only servers)
  8. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  9. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
  10. tcp6 0 0 :::22 :::* LISTEN -
  11. [mysql@riyimei ~]$

开启远程登陆

  1. 改表
  2. #登录数据库:mysql -u root -p
  3. mysql>use mysql;
  4. mysql>update user set host = '%' where user = 'root';
  5. mysql>FLUSH PRIVILEGES;

image.png