广告
返回顶部
首页 > 资讯 > 数据库 >Linux环境MySQL5.6安装实践
  • 200
分享到

Linux环境MySQL5.6安装实践

2024-04-02 19:04:59 200人浏览 独家记忆
摘要

      Mysql的安装相对于oracle来说非常简单,个人觉得与TimesTen的安装配置更为接近,而且后面的Master-Slave或Master-Master集群配置

      Mysql的安装相对于oracle来说非常简单,个人觉得与TimesTen的安装配置更为接近,而且后面的Master-Slave或Master-Master集群配置更为简单,甚至比TimesTen的ASP/Active-Active/Active-Standby配置都比TimesTen还要简单,不过mysql涉及的初始化参数还是比较多,初始化参数配置不合理Mysql将很难启动,这次安装MySQL感觉比十年前第一次安装Oracle RAC还折腾,百度了一圈感觉网上的步骤清晰一点的都是使用cmake这个包来安装,所以这里纪录一下安装步骤,或许有对初次接触MySQL的兄弟会有帮助。
安装步骤:
1、安装MySQL数据库软件rpm包
2、配置MySQL数据库参数文件my.cnf
3、初始化MySQL数据库实例
4、启动MySQL服务进程mysqld
5、修改登录密码和检查数据库参数

一、操作系统环境
IP:192.168.100.71 tony7
操作系统版本:
  # uname -a
linux tony7 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
 
# free -g
             total       used       free     shared    buffers     cached
Mem:             1          0          1          0          0          0
-/+ buffers/cache:          0          1
Swap:            3          0          3

df -h

# rpm -qa|grep -i mysql
mysql-5.1.47-4.el6.x86_64
perl-DBD-MySQL-4.013-3.el6.x86_64
mysql-libs-5.1.47-4.el6.x86_64
Qt-mysql-4.6.2-16.el6.x86_64
mysql-server-5.1.47-4.el6.x86_64

[root@tony7 soft]# rpm -e --nodeps mysql-5.1.47-4.el6.x86_64
[root@tony7 soft]# rpm -e --nodeps perl-DBD-MySQL-4.013-3.el6.x86_64
[root@tony7 soft]# rpm -e --nodeps mysql-libs-5.1.47-4.el6.x86_64
[root@tony7 soft]# rpm -e --nodeps qt-mysql-4.6.2-16.el6.x86_64
[root@tony7 soft]# rpm -e --nodeps mysql-server-5.1.47-4.el6.x86_64
如果已安装,则需要删除已安装的数据库,使用以下命令来删除数据库
删除命令:rpm -e --nodeps 包名
( rpm -ev mysql-4.1.12-3.RHEL4.1 )
删除老版本mysql的开发头文件和库
命令:rm -fr /usr/lib/mysql
rm -fr /usr/include/mysql
注意:卸载后/var/lib/mysql中的数据及/etc/my.cnf不会删除,如果确定没用后就手工删除
rm -f /etc/my.cnf
rm -fr /var/lib/mysql

二、安装数据库软件
    MySQL-server-5.6.28-1.el6.x86_64.rpm
    MySQL-client-5.6.28-1.el6.x86_64.rpm
    MySQL-devel-5.6.28-1.el6.x86_64.rpm
    
# rpm -ivh MySQL-server-5.6.28-1.el6.x86_64.rpm 
warning: MySQL-server-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
2016-01-18 14:42:21 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-18 14:42:21 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1671 ...
2016-01-18 14:42:21 1671 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-18 14:42:21 1671 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-18 14:42:21 1671 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-18 14:42:21 1671 [Note] InnoDB: Memory barrier is not used
2016-01-18 14:42:21 1671 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-18 14:42:21 1671 [Note] InnoDB: Using Linux native AIO
2016-01-18 14:42:21 1671 [Note] InnoDB: Using CPU crc32 instructions
2016-01-18 14:42:21 1671 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-18 14:42:21 1671 [Note] InnoDB: Completed initialization of buffer pool
2016-01-18 14:42:21 1671 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-18 14:42:21 1671 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-18 14:42:21 1671 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-18 14:42:21 1671 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-18 14:42:22 1671 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-18 14:42:22 1671 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-18 14:42:22 1671 [Warning] InnoDB: New log files created, LSN=45781
2016-01-18 14:42:22 1671 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-18 14:42:22 1671 [Note] InnoDB: Doublewrite buffer created
2016-01-18 14:42:22 1671 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-18 14:42:22 1671 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-18 14:42:22 1671 [Note] InnoDB: Foreign key constraint system tables created
2016-01-18 14:42:22 1671 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-18 14:42:22 1671 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-18 14:42:22 1671 [Note] InnoDB: Waiting for purge to start
2016-01-18 14:42:22 1671 [Note] InnoDB: 5.6.28 started; log sequence number 0
A random root passWord has been set. You will find it in '/root/.mysql_secret'.
2016-01-18 14:42:22 1671 [Note] Binlog end
2016-01-18 14:42:22 1671 [Note] InnoDB: FTS optimize thread exiting.
2016-01-18 14:42:22 1671 [Note] InnoDB: Starting shutdown...
2016-01-18 14:42:24 1671 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2016-01-18 14:42:24 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-18 14:42:24 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1693 ...
2016-01-18 14:42:24 1693 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-18 14:42:24 1693 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-18 14:42:24 1693 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-18 14:42:24 1693 [Note] InnoDB: Memory barrier is not used
2016-01-18 14:42:24 1693 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-18 14:42:24 1693 [Note] InnoDB: Using Linux native AIO
2016-01-18 14:42:24 1693 [Note] InnoDB: Using CPU crc32 instructions
2016-01-18 14:42:24 1693 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-18 14:42:24 1693 [Note] InnoDB: Completed initialization of buffer pool
2016-01-18 14:42:24 1693 [Note] InnoDB: Highest supported file fORMat is Barracuda.
2016-01-18 14:42:24 1693 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-18 14:42:24 1693 [Note] InnoDB: Waiting for purge to start
2016-01-18 14:42:24 1693 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2016-01-18 14:42:24 1693 [Note] Binlog end
2016-01-18 14:42:24 1693 [Note] InnoDB: FTS optimize thread exiting.
2016-01-18 14:42:24 1693 [Note] InnoDB: Starting shutdown...
2016-01-18 14:42:26 1693 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

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

# rpm -ivh MySQL-devel-5.6.28-1.el6.x86_64.rpm 
warning: MySQL-devel-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]
[root@tony7 soft]# rpm -ivh MySQL-client-5.6.28-1.el6.x86_64.rpm 
warning: MySQL-client-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

创建相关文件夹并授权于mysql用户
#mkdir -p /mysql/data/mysqldata/mydata
#mkdir -p /mysql/data/mysqldata/innodb_log
#mkdir -p /mysql/data/mysqldata/innodb_ts
#mkdir -p /mysql/data/mysqldata/log
#mkdir -p /mysql/data/mysqldata/sock
#mkdir -p /mysql/data/mysqldata/tmpdir
# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
#chown -R mysql:mysql /mysql/data

把mysql开机自启关闭
#chkconfig --level 2345 mysql off
# chkconfig --list mysql
mysql           0:off   1:off   2:off   3:off   4:off   5:off   6:off

三、配置MySQL数据库参数文件my.cnf
编辑 my.cnf文件
#vi /usr/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 512M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
 basedir = /usr
 datadir = /mysql/data/mysqldata/mydata
 port = 3306
 Socket = /mysql/data/mysqldata/sock/mysql.sock
 tmpdir=/mysql/data/mysqldata/tmpdir

#add by tangyun
 innodb_data_home_dir =/mysql/data/mysqldata/ibdata
 innodb_log_group_home_dir=/mysql/data/mysqldata/ibdata
 log-bin-index=/mysql/data/mysqldata/binlog/mysql-bin.index
 log-bin=/mysql/data/mysqldata/binlog/mysql-bin
 innodb_buffer_pool_size = 512M
 innodb_buffer_pool_instances=4
 innodb_flush_log_at_trx_commit=2
 innodb_log_files_in_group=3
 innodb_log_file_size=256M

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
 join_buffer_size = 128M
 sort_buffer_size = 2M
 read_rnd_buffer_size = 2M 

#add by tangyun
performance_schema=0
event-scheduler=ON
default-storage-engine=InnoDB
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci
lower_case_table_names=1
explicit_defaults_for_timestamp=true

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
optimizer_switch=index_merge=on,index_merge_uNIOn=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=on,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on

#add by tangyun
#*******************************  Logs related settings ***************************
#general_log
general_log_file=/mysql/data/mysqldata/log/general.log
log-error=/mysql/data/mysqldata/log/error.log
long_query_time=0.3
slow_query_log =1
slow_query_log_file=/mysql/data/mysqldata/log/slow-query.log
#log_queries_not_using_indexes
log_warnings = 2

relay-log-index=/mysql/data/mysqldata/relaylog/mysql-relay-bin.index
relay-log=/mysql/data/mysqldata/relaylog/mysql-relay-bin

binlog_cache_size=256K
max_binlog_size=512M
binlog_format=mixed
binlog_checksum=crc32
sync_binlog=100
expire_logs_days=10

##add by tangyun
#*******************************  Replication related settings **********************
server_id = 1000
#slave-skip-errors=1022,1032,1062
log_slave_updates=1
log_bin_trust_function_creators=1
auto_increment_increment=2
auto_increment_offset=1
allow-suspicious-udfs
innodb_support_xa=1
sysdate-is-now

#gtid-mode=ON
#enforce_gtid_consistency
#disable_gtid_unsafe_statements

[mysqldump]
quick
max_allowed_packet=2G
default-character-set=utf8


[mysql]
no-auto-rehash
default-character-set=utf8
show-warnings
pager=mk-visual-explain
prompt="(\u@\h) [\d]> "

[myisamchk]
key_buffer=512M
sort_buffer_size=512M
read_buffer=8M
write_buffer=8M

[mysqlhotcopy]
#interactive-timeout

[mysqld_safe]
#ledir=/usr/bin
user=mysql
open-files-limit=8192

四、初始化MySQL数据库实例
# mysql_install_db --user=mysql --explicit_defaults_for_timestamp=true --datadir=/mysql/data/mysqldata/mydata
Installing MySQL system tables...2016-01-28 08:37:12 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 10719 ...
2016-01-28 08:37:12 10719 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-28 08:37:12 10719 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-28 08:37:12 10719 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-28 08:37:12 10719 [Note] InnoDB: Memory barrier is not used
2016-01-28 08:37:12 10719 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-28 08:37:12 10719 [Note] InnoDB: Using Linux native AIO
2016-01-28 08:37:12 10719 [Note] InnoDB: Using CPU crc32 instructions
2016-01-28 08:37:12 10719 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-28 08:37:12 10719 [Note] InnoDB: Completed initialization of buffer pool
2016-01-28 08:37:12 10719 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-28 08:37:12 10719 [Warning] InnoDB: New log files created, LSN=45781
2016-01-28 08:37:12 10719 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-28 08:37:12 10719 [Note] InnoDB: Doublewrite buffer created
2016-01-28 08:37:12 10719 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-28 08:37:12 10719 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-28 08:37:12 10719 [Note] InnoDB: Foreign key constraint system tables created
2016-01-28 08:37:12 10719 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-28 08:37:12 10719 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-28 08:37:12 10719 [Note] InnoDB: Waiting for purge to start
2016-01-28 08:37:12 10719 [Note] InnoDB: 5.6.28 started; log sequence number 0
2016-01-28 08:37:12 10719 [Note] Binlog end
2016-01-28 08:37:12 10719 [Note] InnoDB: FTS optimize thread exiting.
2016-01-28 08:37:12 10719 [Note] InnoDB: Starting shutdown...
2016-01-28 08:37:14 10719 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2016-01-28 08:37:14 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 10741 ...
2016-01-28 08:37:14 10741 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-28 08:37:14 10741 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-28 08:37:14 10741 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-28 08:37:14 10741 [Note] InnoDB: Memory barrier is not used
2016-01-28 08:37:14 10741 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-28 08:37:14 10741 [Note] InnoDB: Using Linux native AIO
2016-01-28 08:37:14 10741 [Note] InnoDB: Using CPU crc32 instructions
2016-01-28 08:37:14 10741 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-28 08:37:14 10741 [Note] InnoDB: Completed initialization of buffer pool
2016-01-28 08:37:14 10741 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-28 08:37:14 10741 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-28 08:37:14 10741 [Note] InnoDB: Waiting for purge to start
2016-01-28 08:37:14 10741 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2016-01-28 08:37:14 10741 [Note] Binlog end
2016-01-28 08:37:14 10741 [Note] InnoDB: FTS optimize thread exiting.
2016-01-28 08:37:14 10741 [Note] InnoDB: Starting shutdown...
2016-01-28 08:37:16 10741 [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 tony7 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

五、启动MySQL服务进程mysqld
cp /usr/share/mysql/mysql.server /etc/init.d/mysqld
# service mysqld start
Starting MySQL... SUCCESS! 

# netstat -npl|grep mysql
tcp        0      0 :::3306                     :::*                        LISTEN      11254/mysqld        
unix  2      [ ACC ]     STREAM     LISTENING     21155  11254/mysqld        /mysql/data/mysqldata/sock/mysql.sock

六、修改登录密码和检查数据库参数
mysqladmin -u root -h tony7 password 'mysql'
[root@tony7 ~]# mysql -uroot -pmysql -htony7
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.28-log MySQL CommUnity Server (GPL)

Copyright (c) 2000, 2015, 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> set password for 'root'@'localhost' = password('mysql');
Query OK, 0 rows affected (0.00 sec)

mysql> use mysql
Database changed
mysql> drop database test ;
Query OK, 0 rows affected (0.00 sec)

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

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

mysql> show global variables like '%slow%';
+---------------------------+------------------------------------------+
| Variable_name             | Value                                    |
+---------------------------+------------------------------------------+
| log_slow_admin_statements | OFF                                      |
| log_slow_slave_statements | OFF                                      |
| slow_launch_time          | 2                                        |
| slow_query_log            | ON                                       |
| slow_query_log_file       | /mysql/data/mysqldata/log/slow-query.log |
+---------------------------+------------------------------------------+
5 rows in set (0.00 sec)

mysql> show global variables like '%log-bin%';
Empty set (0.00 sec)

mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | tony7     |                                           |
| root | 127.0.0.1 |                                           |
| root | ::1       |                                           |
|      | localhost |                                           |
|      | tony7     |                                           |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql> show global variables like '%event%';
+--------------------------------------------------------+-------+
| Variable_name                                          | Value |
+--------------------------------------------------------+-------+
| binlog_rows_query_log_events                           | OFF   |
| event_scheduler                                        | OFF   |
| log_bin_use_v1_row_events                              | OFF   |
| performance_schema_events_stages_history_long_size     | 10000 |
| performance_schema_events_stages_history_size          | 10    |
| performance_schema_events_statements_history_long_size | 10000 |
| performance_schema_events_statements_history_size      | 10    |
| performance_schema_events_waits_history_long_size      | 10000 |
| performance_schema_events_waits_history_size           | 10    |
+--------------------------------------------------------+-------+
9 rows in set (0.00 sec)

mysql> show full processlist;
+----+------+-----------------+-------+---------+------+-------+-----------------------+
| Id | User | Host            | db    | Command | Time | State | Info                  |
+----+------+-----------------+-------+---------+------+-------+-----------------------+
|  1 | root | localhost:24980 | mysql | Query   |    0 | init  | show full processlist |
+----+------+-----------------+-------+---------+------+-------+-----------------------+
1 row in set (0.00 sec)

mysql> set password for 'root'@'tony7' = password('mysql');
Query OK, 0 rows affected (0.00 sec)

mysql> set password for 'root'@'127.0.0.1' = password('mysql');
Query OK, 0 rows affected (0.00 sec)

mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | tony7     | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | 127.0.0.1 | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | ::1       |                                           |
|      | localhost |                                           |
|      | tony7     |                                           |
+------+-----------+-------------------------------------------+
6 rows in set (0.00 sec)

mysql> delete from mysql.user where host='::1';
Query OK, 1 row affected (0.00 sec)

mysql> delete from mysql.user where host='tony7' and user='';
Query OK, 1 row affected (0.00 sec)

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

mysql> delete from mysql.user where host='localhost' and user='';
Query OK, 1 row affected (0.00 sec)

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

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

mysql> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | tony7     | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
| root | 127.0.0.1 | *E74858DB86EBA20BC33D0AECAE8A8108C56B17FA |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)

mysql> 
#export MYSQL_PS1="(\u@\h) [\d]> "
(root@localhost) [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

Created by Tony.Tang[TangYun]2016.01
-----------------End-----------------
您可能感兴趣的文档:

--结束END--

本文标题: Linux环境MySQL5.6安装实践

本文链接: https://www.lsjlt.com/news/47477.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Linux环境MySQL5.6安装实践
          MySQL的安装相对于Oracle来说非常简单,个人觉得与TimesTen的安装配置更为接近,而且后面的Master-Slave或Master-Master集群配置...
    99+
    2022-10-18
  • centos7环境下二进制安装包怎么安装mysql5.6
    这篇文章主要介绍centos7环境下二进制安装包怎么安装mysql5.6,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!本文实例讲述了centos7环境下二进制安装包安装 mysql5...
    99+
    2022-10-18
  • Linux环境安装unzip
    目录 1. 下载unzip源码2.解压3.进入解压目录4.将Makefile从unix子目录复制到当前目录5.安装 1. 下载unzip源码 sudo wget http://downl...
    99+
    2023-08-31
    linux 服务器 运维
  • Linux环境Hbase安装
    环境准备 System:CentOS release 6.10 (Final) JDK:jdk1.8.0_251 注意,不同版本的安装包需要相应的jdk版本支持 step1下载安装包: # wget http://ftp.mirror.t...
    99+
    2019-09-23
    Linux环境Hbase安装
  • Linux安装Python环境
    linux系统环境自带python2.6,但有时我们项目使用的版本可能是3.x以上等等,此时我们需要在linux中再安装项目所需的python版本,此时就涉及多版本共存问题了,很多同学在安装多个版本Python时会遇到各种问题,本篇文章...
    99+
    2023-01-31
    环境 Linux Python
  • linux安装golang环境
    随着互联网、人工智能等领域的不断发展,编程语言也在日新月异地更新,Go就是其中之一。Go是谷歌开发的一款开源的编程语言,它具有高效、稳定、简洁等特点,受到了众多程序员的欢迎。本文将介绍在Linux系统下安装golang环境的详细步骤,帮助初...
    99+
    2023-05-14
  • linux安装php环境
    linux安装php环境 首先,打开终端并更新系统的软件包列表。运行以下命令然后安装 PHP。运行以下命令安装完成后,可以使用以下命令检查 PHP 的版本:如果您需要使用 PHP 的扩展,可以...
    99+
    2023-08-31
    php linux apache
  • 【linux】 安装 java 环境
    目录 1.检查linux 下是否安装java(jdk)环境2.查看 linux 的操作系统版本3.下载jdk4.新建java文件夹用于安装jdk5.将下载到本地的jdk压缩包上传到linux服...
    99+
    2023-09-03
    linux java 服务器
  • 【Linux】Linux安装Java环境(OpenJDK)
    文章目录 第一步:第二步,选择合适的版本安装:第四步,配置环境变量 linux环境为CentOS7.8 版本。 今天教大家怎么在CentOs环境中安装Java的开发环境。 在安装ja...
    99+
    2023-09-03
    linux java jvm
  • Linux环境下怎么安装docker环境
    这篇文章主要介绍“Linux环境下怎么安装docker环境”,在日常操作中,相信很多人在Linux环境下怎么安装docker环境问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux环境下怎么安装docke...
    99+
    2023-06-22
  • Linux环境下安装python3
    1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Python-3.6.5.tgz 说明:这句话的作用主要是...
    99+
    2022-07-08
    Linux 安装python3
  • Linux环境下安装MongoDB
    下载安装包 下载地址:https://www.mongodb.com/download-center/community curl -O https://fastdl.mongodb.org/linux/mongodb-linux...
    99+
    2017-05-27
    Linux环境下安装MongoDB
  • Linux环境下安装Redis
      1.Linux环境下安装Redis   (1)下载Redis安装包,并解压到安装路径【没有wget就使用yum install wget安装】 [root@localhost ~]#wget http://download.r...
    99+
    2017-09-26
    Linux环境下安装Redis
  • Linux环境下安装JDK1.8
    目录一、安装环境二、安装步骤第一步:下载安装包第二步、解压安装包第三步、修改环境变量第四步、测试是否安装成功本文主要介绍的是如何是linux环境下安装JDK的,因为Linux环境下,很多时候也离不开java的,下面笔者就...
    99+
    2022-06-04
    Linux环境安装JDK Linux安装JDK Linux安装JDK1.8
  • linux环境Mysql 5.7.13安装
    http://www.cnblogs.com/zhao1949/p/5947938.html linux环境Mysql 5.7.13安装教程分享给大家,供大家参考,具体内容如下 ...
    99+
    2022-10-18
  • centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解
    centos7和centos6.5环境rpm方式安装mysql5.7和mysql5.6详解centos环境安装mysql5.7其实不建议安装mysql5.7 语法和配置可能和以前的版本区别较大,多坑,慎入1...
    99+
    2022-10-18
  • Linux下源码安装mysql5.6
    1、下载mysql到/usr/local/src/cd /usr/local/src/ wget http://distfiles.macports.org/cmake/cmake-2....
    99+
    2022-10-18
  • Linux怎么安装Go环境
    这篇文章将为大家详细讲解有关Linux怎么安装Go环境,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。Go(又称 Golang) 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易...
    99+
    2023-06-28
  • 在Linux环境下安装Kafka
    目录二、生产与消费2.1 kafka-topics.sh 用于管理主题2.2 kafka-console-consumer.sh用于消费消息2.3 kafka-console-producer.sh用于生产消息2.4 具...
    99+
    2022-06-04
    Kafka安装 Kafka
  • Linux环境下mysql的安装
    1、环境准备 (1)卸载自带的Mariadb 命令:rpm –qa|grep mariadb  ---------查询已经安装的mariadb rpm –e –nodeps 文件名------------------卸载mariadb (...
    99+
    2019-03-30
    Linux环境下mysql的安装 数据库入门 数据库基础教程 数据库 mysql
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作