CentOS7安装mysql
Adding the MySQL Yum Repository
First, add the MySQL Yum repository to your system's repository list. Follow these steps:
-
Go to the download page for MySQL Yum repository at http://dev.mysql.com/downloads/repo/yum/.
-
Select and download the release package for your platform.
-
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
.rpmFor 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.
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]#
相关推荐
CentOS 7 安装 MySQL
提供的文档“CentOS7安装mysql5.7.19.docx”和“mysql5.7.19主从配置(CentOS7).docx”应包含更详细的步骤和可能遇到的问题解决方案,建议仔细阅读以获取完整信息。在实际操作过程中,务必遵循最佳实践,确保系统的...
"Centos7安装mysql8.0压缩包" 本文档详细介绍了在Centos7系统上安装mysql8.0的步骤,包括卸载系统自带的mariadb,安装mysql依赖项,上传和解压mysql压缩包,创建安装目录、mysql用户和组,创建数据目录和配置文件,...
解决CentOS 7安装mysql后3306端口不通
CentOS7 安装 MySQL8.0 图文教程 本文将指导读者在 CentOS7 系统中安装 MySQL 8.0,以下是安装过程中需要注意的知识点: 1. 下载 MySQL 安装包:在 MySQL 官方网站下载 MySQL 8.0 安装包,选择 Red Hat 作为操作...
### CentOS7安装MySQL教程 #### 一、简介 在Linux环境下安装MySQL数据库是常见的系统管理任务之一。本文将详细介绍如何在CentOS 7系统上安装MySQL,并提供一系列实用的命令来帮助用户完成整个过程。 #### 二、...
CentOS 7 安装 MySQL 5.7.28 详细完整教程 MySQL 是一种关系型数据库管理系统,广泛应用于各种 Web 应用程序中。在本教程中,我们将详细介绍如何在 CentOS 7 中安装 MySQL 5.7.28。 知识点1:下载 MySQL 源 在...
在本地虚拟机的场合,需要更换yum安装网络地址配置文件CentOS-Base.repo 从阿里云服务器下载一份CentOS-Base.repo文件存到本地
centos7安装mysql方法
### CentOS 7 安装 MySQL 5.7.21 的详细步骤 #### 一、前期准备 在开始安装MySQL之前,确保您的CentOS 7系统已经更新至最新版本,并且具备基本的操作权限。 #### 二、卸载可能存在的MariaDB数据库 CentOS 7系统...
centos7安装mysql8以及常规操作 ------------------------------------- [root@...opt]# vi /etc/my.cnf [mysqld] socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/...
该文档是关于在centos7安装mysql5.7.22数据库的详细步骤,亲测没有问题
本文将详细介绍如何在CentOS 7上安装MySQL 5.7,基于提供的安装包进行操作。 首先,我们需要了解MySQL的组件结构。在提供的压缩包文件中,包含了以下几个MySQL的组件: 1. `mysql-community-server-5.7.13-1.el7....
首先,让我们关注标题中的"CentOS 7安装MySQL"。CentOS 7是一个基于Linux的开源操作系统,广泛用于服务器部署。MySQL是一款流行的开源关系型数据库管理系统,它提供高效、可靠的数据存储和处理能力。在CentOS 7上...
centos7安装mysql 亲身实操,百分百成功,安装的是mysql5.7
"CentOS 7 安装 MySQL 数据库详解" 在本篇文章中,我们将详细介绍如何在 CentOS 7 中安装 MySQL 数据库,包括解决常见的 bug 和安装过程中可能遇到的问题。 为什么选择 MySQL MySQL 是一个开源的关系型数据库管理...
CentOS 7 安装 MySQL 8.0 本文档将指导你如何在 CentOS 7 上安装 MySQL 8.0,并解决可能遇到的大小写问题和远程访问问题。 一、卸载 CentOS 7 自带的 MariaDB 在安装 MySQL 8.0 之前,我们需要卸载 CentOS 7 自带...
在压缩包文件"centos7安装mysql5.x数据库"中,可能包含了上述所有步骤的详细脚本,用于自动化安装过程。使用这样的脚本可以大大提高效率,特别是在需要批量部署的场景下。在使用前,务必根据实际情况对脚本进行适当...
Centos7安装mysql8