In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Installation method
There are four common ways to install mysql
The serial number installation method shows that 1yum\ rpm is simple and fast, and can not be customized by binary decompression of parameter 2. With simple configuration, you can use installation-free mysql-a.b.c-linux2.x-x86_64.tar.gz3 source code compilation to customize parameters, install long time mysql-a.b.c.tar.gz4 source code into rpm package, make the source code into rpm that meets the requirements, and install through yum.
2. Installation steps
Create a mysql user
Groupadd mysql
Useradd-s / sbin/nologin-g mysql-M mysql (no home directory is created)
Get the software package
You can choose a domestic sohu image site to download.
Http://mirrors.sohu.com/mysql/ can choose another version to use.
Http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
Binary installation
[root@bj-web-001 opt] # cd / opt/
[root@bj-web-001 opt] # wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz
[root@bj-web-001 opt] # tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz
[root@bj-web-001 opt] # ln-s mysql-5.5.55-linux2.6-x86_64 mysql
[root@bj-web-001 opt] # ls-l mysql
Lrwxrwxrwx 1 root root 28 June 27 22:13 mysql- > mysql-5.5.55-linux2.6-x86_64
[root@bj-web-001 mysql] # ls-l support-files/*.cnf
-rw-r--r-- 1 7161 31415 4691 March 18 13:14 support-files/my-huge.cnf
-rw-r--r-- 1 7161 31415 19759 March 18 13:14 support-files/my-innodb-heavy-4G.cnf
-rw-r--r-- 1 7161 31415 4665 March 18 13:14 support-files/my-large.cnf
-rw-r--r-- 1 7161 31415 4676 March 18 13:14 support-files/my-medium.cnf
-rw-r--r-- 1 7161 31415 2840 March 18 13:14 support-files/my-small.cnf
[root@bj-web-001 mysql] # / bin/cp support-files/my-small.cnf / etc/my.cnf
[root@bj-web-001] # chown-R mysql.mysql / opt/mysql/
[root@bj-web-001 ~] # ll / opt/mysql/
Total dosage 72
Drwxr-xr-x 2 mysql mysql 4096 June 27 22:08 bin
-rw-r--r-- 1 mysql mysql 17987 March 18 12:41 COPYING
Drwxr-xr-x 3 mysql mysql 4096 June 27 22:08 data
Drwxr-xr-x 2 mysql mysql 4096 June 27 22:08 docs
Drwxr-xr-x 3 mysql mysql 4096 June 27 22:08 include
-rw-r--r-- 1 mysql mysql 301 March 18 12:41 INSTALL-BINARY
Drwxr-xr-x 3 mysql mysql 4096 June 27 22:09 lib
Drwxr-xr-x 4 mysql mysql 4096 June 27 22:08 man
Drwxr-xr-x 10 mysql mysql 4096 June 27 22:09 mysql-test
-rw-r--r-- 1 mysql mysql 2496 March 18 12:41 README
Drwxr-xr-x 2 mysql mysql 4096 June 27 22:08 scripts
Drwxr-xr-x 27 mysql mysql 4096 June 27 22:09 share
Drwxr-xr-x 4 mysql mysql 4096 June 27 22:08 sql-bench
Drwxr-xr-x 2 mysql mysql 4096 June 27 22:08 support-files
[root@bj-web-001] # / opt/mysql/scripts/mysql_install_db-basedir=/opt/mysql-datadir=/opt/mysql/data/-user=mysql
[root@bj-web-001 ~] # tree / opt/mysql/data/
/ opt/mysql/data/
├── mysql
│ ├── columns_priv.frm
│ ├── columns_priv.MYD
│ ├── columns_priv.MYI
│ ├── db.frm
│ ├── db.MYD
│ ├── db.MYI
│ ├── event.frm
│ ├── event.MYD
│ ├── event.MYI
│ ├── func.frm
│ ├── func.MYD
│ ├── func.MYI
[root@bj-web-001 mysql] # cp support-files/mysql.server / etc/init.d/mysqld
[root@bj-web-001 mysql] # chmod + x / etc/init.d/mysqld
[root@bj-web-001 mysql] # sed-I's license engine usr _ opt/mysql/bin/mysqld_safe _ opt/mysql/bin/mysqld_safe _ etc/init.d/mysqld
[root@bj-web-001 mysql] # / etc/init.d/mysqld start
Starting MySQL.Logging to'/ opt/mysql/data/bj-web-001.err'.
. SUCCESS!
You can also use (2 choose 1)
[root@bj-web-001 mysql] # / opt/mysql/bin/mysqld_safe-- user=mysql &
[root@bj-web-001 mysql] # netstat-ntpl | grep mysql
Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN 58844/mysqld
If the startup fails, you need to check the log
[root@bj-web-001 mysql] # tail-f data/bj-web-001.err
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
Set up boot boot
[root@bj-web-001 data] # chkconfig-- add mysqld
[root@bj-web-001 data] # chkconfig mysqld on
[root@bj-web-001 data] # chkconfig-- list mysqld
Mysqld 0: off 1: off 2: enable 3: enable 4: enable 5: enable 6: close
Configure environment variables
[root@bj-web-001 data] # echo 'export PATH=/opt/mysql/bin:$PATH' > > / etc/profile
[root@bj-web-001 data] # tail-1 / etc/profile
Export PATH=/opt/mysql/bin:$PATH
[root@bj-web-001 data] # source / etc/profile
[root@bj-web-001 data] # echo $PATH
/ opt/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Test login
[root@bj-web-001 data] # mysql
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 1
Server version: 5.5.55 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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 > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
+-+
4 rows in set (0.00 sec)
Mysql > select user ()
+-+
| | user () |
+-+
| | root@localhost |
+-+
1 row in set (0.00 sec)
Mysql >\ Q
Bye
Set password
[root@bj-web-001 data] # mysqladmin-u root password '123456'
[root@bj-web-001 data] # mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@bj-web-001 data] # mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 4
Server version: 5.5.55 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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 >
Delete useless account
Mysql > DELETE FROM mysql.user WHERE user =''; [delete anonymous account]
Mysql > select user,host from mysql.user
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | root |:: 1 |
| | bj-web-001 |
| | root | bj-web-001 |
| | localhost |
| | root | localhost |
+-+ +
6 rows in set (0.00 sec)
Mysql > drop user "root" @ ":: 1"
Query OK, 0 rows affected (0.00 sec)
Mysql > drop user "" @ "localhost"
Query OK, 0 rows affected (0.00 sec)
Mysql > drop user "" @ "bj-web-001"
Query OK, 0 rows affected (0.00 sec)
Mysql > drop user "root" @ "bj-web-001"
Query OK, 0 rows affected (0.00 sec)
Mysql > select user,host from mysql.user
+-+ +
| | user | host |
+-+ +
| | root | 127.0.0.1 | |
| | root | localhost |
+-+ +
2 rows in set (0.00 sec)
Mysql > flush privileges
Query OK, 0 rows affected (0.00 sec)
Delete useless database
Mysql > drop database test
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 >
At this point, the binary installation of the mysql database is complete.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.