Download MySQL for all platforms: MySQL download . You need to choose the version of MySQL Community Server and the corresponding platform.
Note: The installation process we need to install by opening administrator rights, otherwise it will lead to the installation due to insufficient permissions.
Installing MySQL on Linux / UNIX
Recommended on Linux RPM package to install Mysql, MySQL AB provides Download the RPM package:
MySQL - MySQL server. You need this option unless you want to connect to another machine running MySQL server.
MySQL-client - MySQL client program to connect and operate the server Mysql.
MySQL-devel - Libraries and include files, if you want to compile other MySQL clients, such as Perl module, you need to install the RPM package.
MySQL-shared - This package contains certain languages and applications need to dynamically load shared libraries (libmysqlclient.so *), the use of MySQL.
MySQL-bench - benchmark and performance testing tool for MySQL database server.
Before installation, we can detect whether the system comes installed MySQL:
rpm -qa | grep mysql
If you have 40, you can choose to uninstall:
rpm -e mysql // delete common mode
rpm -e --nodeps mysql // strong delete mode, if you use the above command to delete, suggesting other files rely on, use the delete command can be strong
Install MySQL:
Next we use in Centos7 system command yum install MySQL, to note that CentOS 7 version of the MySQL database from the default list of programs removed, so we need to go before installing the official website to download Yum resource package, download address : https: //dev.mysql.com/downloads/repo/yum/
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
Permission settings:
chown mysql:mysql -R /var/lib/mysql
Initialization MySQL:
mysqld --initialize
Start MySQL:
systemctl start mysqld
View MySQL running state:
systemctl status mysqld
Note: If we are the first start mysql service, mysql server will first be configured to initialize.
In addition, you can use instead of MariaDB, MySQL MariaDB database management system is a branch, mainly by the open source community in the maintenance, under the GPL license. One reason for the development of this branch is: after Oracle's acquisition of MySQL, there are potential risks to MySQL closed source, so the branch community a way to avoid this risk. MariaDB purpose is fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.
yum install mariadb-server mariadb
Mariadb database related commands are:
systemctl start mariadb # start MariaDB
systemctl stop mariadb #停止MariaDB
systemctl restart mariadb #重启MariaDB
systemctl enable mariadb # Set boot
Verify MySQL installation
After a successful installation of MySQL, the table will list some basic initialization, after the server is started, you can verify that MySQL is working correctly by simple tests.
Use mysqladmin tool to get the server status:
Use mysqladmin command both check the server version of linux on the binary file is located in / usr / bin directory on the Windows binary file is located in C: \ mysql \ bin.
[root@host]# mysqladmin --version
On the linux command outputs the following results, the results are based on your system info:
mysqladmin Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386
If the above command no information is entered after execution, state your Mysql is not installed successfully.
Execute simple SQL commands to use MySQL Client (Mysql client)
You can use the MySQL Client (Mysql client) mysql command to connect to the MySQL server, default login password for the MySQL server is empty, so in this instance is not required to enter a password.
Command is as follows:
[root@host]# mysql
After executing the above command output mysql> prompt, indicating that you have successfully connected to the Mysql server, you can mysql> prompt, execute SQL commands:
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.13 sec)
Mysql need to do after installation
Mysql After successful installation, the default root user password is empty, you can create the root password, use the following command:
[root@host]# mysqladmin -u root password "new_password";
Now you can connect to Mysql server with the following command:
[root@host]# mysql -u root -p
Enter password:*******
Note: When you enter the password, the password is not displayed, you can correct input.
Installing MySQL on Windows
Installing MySQL on Windows will be relatively simple, it is a link to download the zip package https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.11-winx64.zip.
The latest versions can be downloaded in the MySQL download.
Click the Download button to go to the download page, click on the figure below No thanks, just start my download download immediately:
Once downloaded, we will extract the zip package to the appropriate directory where the file after I unzip the folder on the C: \ web under \ mysql-8.0.11.
Next we need to configure the MySQL configuration file under
Open just unzip the folder C: \ web \ mysql-8.0.11, create a my.ini configuration file in the folder, edit my.ini configure the following basic information:
[mysql]
# Mysql client to set the default character set
default-character-set=utf8
[mysqld]
Set # 3306 Port
port = 3306
# Set the mysql installation directory
basedir=C:\\web\\mysql-8.0.11
# Set the data storage directory of mysql database, MySQL 8+ does not require the configuration, the system can generate their own, or they may error
# datadir=C:\\web\\sqldata
# Maximum number of connections allowed
max_connections=20
# Server default character set used for the 8-bit coded character set latin1
character-set-server=utf8
The default storage engine that will be used when creating a new table #
default-storage-engine=INNODB
Next we start the next MySQL database:
Administrator cmd to open a command line tool, change directory:
cd C:\web\mysql-8.0.11\bin
Initialize the database:
mysqld --initialize --console
执行完成后,会输出 root 用户的初始默认密码,如:
...
2018-04-20T02:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ
...
APWCY5ws&hjQ 就是初始密码,后续登录需要用到,你也可以在登陆后修改密码。
输入以下安装命令:
mysqld install
启动输入以下命令即可:
net start mysql
注意: 在 5.7 需要初始化 data 目录:
cd C:\web\mysql-8.0.11\bin
mysqld --initialize-insecure
初始化后再运行 net start mysql 即可启动 mysql。
登录 MySQL
当 MySQL 服务已经运行时, 我们可以通过 MySQL 自带的客户端工具登录到 MySQL 数据库中, 首先打开命令提示符, 输入以下格式的命名:
mysql -h 主机名 -u 用户名 -p
参数说明:
-h : 指定客户端所要登录的 MySQL 主机名, 登录本机(localhost 或 127.0.0.1)该参数可以省略;
-u : 登录的用户名;
-p : 告诉服务器将会使用一个密码来登录, 如果所要登录的用户名密码为空, 可以忽略此选项。
如果我们要登录本机的 MySQL 数据库,只需要输入以下命令即可:
mysql -u root -p
按回车确认, 如果安装正确且 MySQL 正在运行, 会得到以下响应:
Enter password:
若密码存在, 输入密码登录, 不存在则直接按回车登录。登录成功后你将会看到 Welecome to the MySQL monitor... 的提示语。
Then the command prompt will have to mysq> add a blinking cursor waiting for entering commands, type exit or quit Log.
Click to see all MySQL Tutorial Articles: https://www.codercto.com/courses/l/30.html (edit: Leilin Peng Source: network intrusion deleted)