`

CentOS7安装mysql

 
阅读更多

CentOS7安装mysql

Adding the MySQL Yum Repository

First, add the MySQL Yum repository to your system's repository list. Follow these steps:

 

  1. Go to the download page for MySQL Yum repository at http://dev.mysql.com/downloads/repo/yum/.

  2. Select and download the release package for your platform.

  3. Install the downloaded release package with the following command, replacing platform-and-version-specific-package-name with the name of the downloaded package:

    shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
    

     

    For example, for version n of the package for EL6-based systems, the command is:

    shell> sudo rpm -Uvh mysql57-community-release-el6-n.noarch.rpm  
    

Selecting a Release Series

When using the MySQL Yum repository, the latest GA release of MySQL is selected for installation by default.

To install the latest release from the latest GA series, no configuration is needed. To install the latest release from a specific series other than the latest GA series, disable the subrepository for the latest GA series and enable the subrepository for the specific series before running the installation command. You can do that by editing manually the /etc/yum.repos.d/mysql-community.repo file. This is a typical entry for a release series' subrepository in the file:

 

[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Find the entry for the subrepository you want to configure, and edit the enabled option. Specify enabled=0 to disable a subrepository, or enabled=1 to enable a subrepository. For example, to install MySQl 5.6, make sure you have enabled=0 for the above subrepository entry for MySQL 5.7, and have enabled=1 for the entry for the 5.6 series:

 

 

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 You should only enable subrepository for one release series at any time. When subrepositories for more than one release series are enabled, the latest series will be used by Yum.

 

Verify that the correct subrepositories have been enabled and disabled by running the following command and checking its output (for dnf-enabled systems, replace yum in the command with dnf):

shell> yum repolist enabled | grep mysql

Installing MySQL

Install MySQL by the following command:

shell> sudo yum install mysql-community-server 

This installs the package for the MySQL server, as well as other required packages.

Note

For MySQL 5.7, a temporary, random root password is generated and stored in the error log, which is /var/log/mysqld.log for an installation using the MySQL Yum repository. You can use this command to see the password:

shell > sudo grep 'temporary password' /var/log/mysqld.log

You should change the root password as soon as possible; see Initializing the Data Directory Using mysqld for instructions.

Starting the MySQL Server

Start the MySQL server with the following command:

shell> sudo service mysqld start

 

You can check the status of the MySQL server with the following command:

shell> sudo service mysqld status

 

 

 

 CentOS 7上MySQL的路径:

在根目录下find结果如下:

[root@localhost /]# find -name mysql
./etc/logrotate.d/mysql
./var/lib/pcp/config/pmlogconf/mysql
./var/lib/pcp/pmdas/mysql
./var/lib/mysql
./var/lib/mysql/mysql
./usr/bin/mysql
./usr/lib64/mysql
./usr/share/mysql

 其中/usr/lib64/mysql目录下是mysql的lib库文件,其中还有插件库目录plugin。

[root@localhost mysql]# ll
total 19372
lrwxrwxrwx. 1 root root       20 Dec 10 15:32 libmysqlclient_r.so.18 -> libmysqlclient.so.18
lrwxrwxrwx. 1 root root       24 Dec 10 15:32 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0
lrwxrwxrwx. 1 root root       24 Dec 10 15:32 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x. 1 root root  9595036 Nov 30 03:37 libmysqlclient.so.18.1.0
lrwxrwxrwx. 1 root root       24 Dec 10 15:32 libmysqlclient.so.20 -> libmysqlclient.so.20.1.0
-rwxr-xr-x. 1 root root 10232314 Nov 30 03:47 libmysqlclient.so.20.1.0
drwxr-xr-x. 4 root root       26 Dec 10 15:32 mecab
drwxr-xr-x. 3 root root     4096 Dec 10 15:32 plugin

 plugin目录下的validate_password.so库文件是在修改MySQl密码是提示如下错误信息的罪魁祸首。

[root@localhost mysql]# ll plugin/
total 13280
-rwxr-xr-x. 1 root root   96431 Nov 30 03:46 adt_null.so
-rwxr-xr-x. 1 root root   51567 Nov 30 03:46 auth_socket.so
drwxr-xr-x. 2 root root    4096 Dec 10 15:32 debug
-rwxr-xr-x. 1 root root  389695 Nov 30 03:45 ha_example.so
-rwxr-xr-x. 1 root root  893413 Nov 30 03:46 innodb_engine.so
-rwxr-xr-x. 1 root root  806993 Nov 30 03:46 libmemcached.so
-rwxr-xr-x. 1 root root 8991266 Nov 30 03:46 libpluginmecab.so
-rwxr-xr-x. 1 root root   21261 Nov 30 03:46 locking_service.so
-rwxr-xr-x. 1 root root   57731 Nov 30 03:46 mypluglib.so
-rwxr-xr-x. 1 root root   49307 Nov 30 03:46 mysql_no_login.so
-rwxr-xr-x. 1 root root   57411 Nov 30 03:46 rewrite_example.so
-rwxr-xr-x. 1 root root  591058 Nov 30 03:46 rewriter.so
-rwxr-xr-x. 1 root root  758290 Nov 30 03:46 semisync_master.so
-rwxr-xr-x. 1 root root  157841 Nov 30 03:46 semisync_slave.so
-rwxr-xr-x. 1 root root  209234 Nov 30 03:46 validate_password.so
-rwxr-xr-x. 1 root root  415737 Nov 30 03:46 version_token.so
[root@localhost mysql]# 

 

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('linus_dev!@#123');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

 

/var/lib/mysql目录下是mysql的数据库文件,可以从以下对应关系看出:

[root@localhost mysql]# pwd
/var/lib/mysql
[root@localhost mysql]# ls
auto.cnf    ca.pem           client-key.pem  ibdata1      ib_logfile1  mysql       mysql.sock.lock     private_key.pem  server-cert.pem  sys
ca-key.pem  client-cert.pem  ib_buffer_pool  ib_logfile0  ibtmp1       mysql.sock  performance_schema  public_key.pem   server-key.pem
[root@localhost mysql]# ls mysql
columns_priv.frm  event.frm        gtid_executed.frm  help_topic.ibd          plugin.ibd        proxies_priv.MYI          slave_worker_info.frm  time_zone.ibd                  user.frm
columns_priv.MYD  event.MYD        gtid_executed.ibd  innodb_index_stats.frm  proc.frm          server_cost.frm           slave_worker_info.ibd  time_zone_leap_second.frm      user.MYD
columns_priv.MYI  event.MYI        help_category.frm  innodb_index_stats.ibd  proc.MYD          server_cost.ibd           slow_log.CSM           time_zone_leap_second.ibd      user.MYI
db.frm            func.frm         help_category.ibd  innodb_table_stats.frm  proc.MYI          servers.frm               slow_log.CSV           time_zone_name.frm
db.MYD            func.MYD         help_keyword.frm   innodb_table_stats.ibd  procs_priv.frm    servers.ibd               slow_log.frm           time_zone_name.ibd
db.MYI            func.MYI         help_keyword.ibd   ndb_binlog_index.frm    procs_priv.MYD    slave_master_info.frm     tables_priv.frm        time_zone_transition.frm
db.opt            general_log.CSM  help_relation.frm  ndb_binlog_index.MYD    procs_priv.MYI    slave_master_info.ibd     tables_priv.MYD        time_zone_transition.ibd
engine_cost.frm   general_log.CSV  help_relation.ibd  ndb_binlog_index.MYI    proxies_priv.frm  slave_relay_log_info.frm  tables_priv.MYI        time_zone_transition_type.frm
engine_cost.ibd   general_log.frm  help_topic.frm     plugin.frm              proxies_priv.MYD  slave_relay_log_info.ibd  time_zone.frm          time_zone_transition_type.ibd
[root@localhost mysql]# ls sys/
db.opt                                 schema_redundant_indexes.frm                     wait_classes_global_by_latency.frm             x@0024ps_schema_table_statistics_io.frm
host_summary_by_file_io.frm            schema_table_lock_waits.frm                      waits_by_host_by_latency.frm                   x@0024schema_flattened_keys.frm
host_summary_by_file_io_type.frm       schema_table_statistics.frm                      waits_by_user_by_latency.frm                   x@0024schema_index_statistics.frm
host_summary_by_stages.frm             schema_table_statistics_with_buffer.frm          waits_global_by_latency.frm                    x@0024schema_table_lock_waits.frm
host_summary_by_statement_latency.frm  schema_tables_with_full_table_scans.frm          x@0024host_summary_by_file_io.frm              x@0024schema_table_statistics.frm
host_summary_by_statement_type.frm     schema_unused_indexes.frm                        x@0024host_summary_by_file_io_type.frm         x@0024schema_table_statistics_with_buffer.frm
host_summary.frm                       session.frm                                      x@0024host_summary_by_stages.frm               x@0024schema_tables_with_full_table_scans.frm
innodb_buffer_stats_by_schema.frm      session_ssl_status.frm                           x@0024host_summary_by_statement_latency.frm    x@0024session.frm
innodb_buffer_stats_by_table.frm       statement_analysis.frm                           x@0024host_summary_by_statement_type.frm       x@0024statement_analysis.frm
innodb_lock_waits.frm                  statements_with_errors_or_warnings.frm           x@0024host_summary.frm                         x@0024statements_with_errors_or_warnings.frm
io_by_thread_by_latency.frm            statements_with_full_table_scans.frm             x@0024innodb_buffer_stats_by_schema.frm        x@0024statements_with_full_table_scans.frm
io_global_by_file_by_bytes.frm         statements_with_runtimes_in_95th_percentile.frm  x@0024innodb_buffer_stats_by_table.frm         x@0024statements_with_runtimes_in_95th_percentile.frm
io_global_by_file_by_latency.frm       statements_with_sorting.frm                      x@0024innodb_lock_waits.frm                    x@0024statements_with_sorting.frm
io_global_by_wait_by_bytes.frm         statements_with_temp_tables.frm                  x@0024io_by_thread_by_latency.frm              x@0024statements_with_temp_tables.frm
io_global_by_wait_by_latency.frm       sys_config.frm                                   x@0024io_global_by_file_by_bytes.frm           x@0024user_summary_by_file_io.frm
latest_file_io.frm                     sys_config.ibd                                   x@0024io_global_by_file_by_latency.frm         x@0024user_summary_by_file_io_type.frm
memory_by_host_by_current_bytes.frm    sys_config_insert_set_user.TRN                   x@0024io_global_by_wait_by_bytes.frm           x@0024user_summary_by_stages.frm
memory_by_thread_by_current_bytes.frm  sys_config.TRG                                   x@0024io_global_by_wait_by_latency.frm         x@0024user_summary_by_statement_latency.frm
memory_by_user_by_current_bytes.frm    sys_config_update_set_user.TRN                   x@0024latest_file_io.frm                       x@0024user_summary_by_statement_type.frm
memory_global_by_current_bytes.frm     user_summary_by_file_io.frm                      x@0024memory_by_host_by_current_bytes.frm      x@0024user_summary.frm
memory_global_total.frm                user_summary_by_file_io_type.frm                 x@0024memory_by_thread_by_current_bytes.frm    x@0024wait_classes_global_by_avg_latency.frm
metrics.frm                            user_summary_by_stages.frm                       x@0024memory_by_user_by_current_bytes.frm      x@0024wait_classes_global_by_latency.frm
processlist.frm                        user_summary_by_statement_latency.frm            x@0024memory_global_by_current_bytes.frm       x@0024waits_by_host_by_latency.frm
ps_check_lost_instrumentation.frm      user_summary_by_statement_type.frm               x@0024memory_global_total.frm                  x@0024waits_by_user_by_latency.frm
schema_auto_increment_columns.frm      user_summary.frm                                 x@0024processlist.frm                          x@0024waits_global_by_latency.frm
schema_index_statistics.frm            version.frm                                      x@0024ps_digest_95th_percentile_by_avg_us.frm
schema_object_overview.frm             wait_classes_global_by_avg_latency.frm           x@0024ps_digest_avg_latency_distribution.frm
[root@localhost mysql]# 

 

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

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> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| 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                      |
+---------------------------+
31 rows in set (0.00 sec)

mysql> 

 

/usr/bin目录下有mysql的命令的可执行文件:

[root@localhost bin]# pwd
/usr/bin
[root@localhost bin]# ll mysql*
-rwxr-xr-x. 1 root root 11477801 Nov 30 03:47 mysql
-rwxr-xr-x. 1 root root 10227197 Nov 30 03:47 mysqladmin
-rwxr-xr-x. 1 root root 12213544 Nov 30 03:47 mysqlbinlog
-rwxr-xr-x. 1 root root 10497580 Nov 30 03:47 mysqlcheck
-rwxr-xr-x. 1 root root      819 Nov 30 03:35 mysql_config
-rwxr-xr-x. 1 root root     4907 Nov 30 03:45 mysql_config-64
-rwxr-xr-x. 1 root root  9110273 Nov 30 03:47 mysql_config_editor
-rwxr-xr-x. 1 root root     2611 Nov 30 03:45 mysqld_pre_systemd
-rwxr-xr-x. 1 root root 10582646 Nov 30 03:47 mysqldump
-rwxr-xr-x. 1 root root     7424 Nov 30 03:45 mysqldumpslow
-rwxr-xr-x. 1 root root 10214646 Nov 30 03:47 mysqlimport
-rwxr-xr-x. 1 root root 11553007 Nov 30 03:47 mysql_install_db
-rwxr-xr-x. 1 root root  5648858 Nov 30 03:47 mysql_plugin
-rwxr-xr-x. 1 root root 19144004 Nov 30 03:48 mysqlpump
-rwxr-xr-x. 1 root root 10168274 Nov 30 03:47 mysql_secure_installation
-rwxr-xr-x. 1 root root 10175703 Nov 30 03:47 mysqlshow
-rwxr-xr-x. 1 root root 10286246 Nov 30 03:47 mysqlslap
-rwxr-xr-x. 1 root root  5959171 Nov 30 03:45 mysql_ssl_rsa_setup
-rwxr-xr-x. 1 root root  5171930 Nov 30 03:45 mysql_tzinfo_to_sql
-rwxr-xr-x. 1 root root 13596456 Nov 30 03:47 mysql_upgrade
[root@localhost bin]# 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics