In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Installation by yum
1. Create a directory dedicated to the software installation package
Mkdir / server/tools-pcd / server/tools/
two。 Use wget to download the rpm package of the official Yum source
Wget http://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm
3. Install the RPM package
Yum-y install mysql57-community-release-el7-8.noarch.rpm
4. Use yum to install mysql-server
Yum-y install mysql-community-server.x86_64
5. Start mysql and join the boot auto-boot
Systemctl start mysqldsystemctl enable mysqldnetstat-lntup | grep 3306
6. Modify root local login password
After the mysql installation is complete, a default login password is generated for root in the / var/log/mysqld.log file
[root@db01 /] # grep "temporary password" / var/log/mysqld.log2019-01-14T02:04:55.465890Z 1 [Note] A temporary password is generated for root@localhost: al_gF&9eZUjW# enter the mysql command line and change the password as follows: MyNewPass4! [root@db01 /] # mysql-uroot-p "al_gF&9eZUjW" mysql > set password for 'root'@'localhost'=password (' MyNewPass4password') Note: mysql5.7 installs the password Security check plug-in (validate_password) by default. The default password checking policy requires that passwords must contain uppercase and lowercase letters, numbers and special symbols, and must be no less than 8 digits in length.
7. Modify mysql default password policy
# 1. View the system password policy [root@db01 /] # mysql-uroot-pMyNewPass4!-e "show variables like'% password%';" | grep "length" validate_password_length 8password 2. Add validate_password_policy configuration to / etc/my.cnf configuration file, specify password policy [mysqld] # validate_password_policy=0 # specify one of password policies 0 (LOW), 1 (MEDIUM), 2 (STRONG) Option 2 requires a password dictionary file validate_password = off # disable password policy # restart the mysql service to make the configuration effective: systemctl restart mysqld# modifies the mysql password again [root@db01 /] # mysqladmin-uroot-p password 123456Enter password: # enter the old password MyNewPass4! Complete the Chan
Default profile path:
/ etc/my.cnf # configuration file
/ var/log/mysqld.log # log file
/ var/run/mysqld/mysqld.pid # socket file
If you forget your root password, restore it as follows
# add a sentence to the paragraph of [mysqld]: skip-grant-tables saves and exits vi. Mysql-u rootupdate mysql.user set authentication_string=password ('123qwe') where user='root' and Host =' localhost';flush privileges
2. Binary installation
The MySQL database version 5.7 is installed in binary mode here.
Installation of this method will be quick.
1.yum installs dependency packages (just yum directly)
Yum install ncurses-devel libaio-devel-y
two。 Create mysql user, login method nologin, do not create home directory
Groupadd mysql-g 1002useradd mysql-u 1002-g 1002-s / sbin/nologin-M
3. Upload the mysql software, extract it, move it to the / application directory, and modify the directory name
Mkdir / application mkdir / server/tools-pcd / server/tools/tar xf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gzmv mysql-5.7.20-linux-glibc2.12-x86_64 / application/mysql-5.7.20
4. Create data and tmp directories, and create soft connections and error log files for the mysql home directory
Mkdir / application/mysql-5.7.20/data # for storing database data mkdir / application/mysql-5.7.20/tmp # for storing socket files ln-s / application/mysql-5.7.20/ / application/mysqltouch / application/mysql-5.7.20/mysql.log
5. Use the bin/mysqld command to initialize the mysql database file (according to the actual path)
# initialize database command / application/mysql-5.7.20/bin/mysqld-- initialize-- initialize-- user=mysql-- basedir=/application/mysql-5.7.20-- datadir=/application/mysql-5.7.20/data# here will generate a temporary password for MySQL's first login Need to save 2019-01-13T16:11:48.234884Z 1 [Note] A temporary password is generated for root@localhost:, rK+/7/AvOF: parameter explanation:-- initialize # initialize mysql--user=mysql # specify mysql user-- basedir # specify mysql base directory-- datadir # specify mysql data storage directory
6. Authorize mysql users to manage mysql directories
Chown-R mysql.mysql / application/mysql-5.7.20
7. Configure my.cnf and startup scripts
# 1. Modify the path cd / application/mysql/support-files/sed-I's etc/init.d/mysqld#2 in the startup script content. Configure my.cnf [root@db01 /] # vim / etc/ my.cnf [mysqld] basedir=/application/mysqldatadir=/application/mysql/datasocket=/application/mysql/tmp/mysql.sockcharacter-set-server=utf8port=3306server_id=10log-error=/application/mysql/mysql.loglog-bin=/application/mysql/data/mysql-binbinlog_format=rowskip_name_ resume [MySQL] socket=/application/mysql/tmp/ mysql.sock [mysqladmin] socket=/application/mysql/tmp/mysql.sock#3. Start mysql/etc/init.d/mysqld startnetstat-lntup | grep 3306
8. Configure the environment variable to use the mysql command directly on the command line
Echo 'export "PATH=/application/mysql/bin:$PATH" > > / etc/profilesource / etc/profile
9. Log in to the mysql database using the initialization password
Mysql-uroot-p _ r _ of _ of:
10. Modify initialization password
[root@db01 /] # mysqladmin-uroot-p password 123456Enter password: # enter the old password
3. Install with source code
Source code compilation and installation of MySQL5.7
Here you install version 5.7 of the MySQL database by compiling
1. Install the dependency package (just yum directly)
Before installing MySQL, it is best to install the dependent package of MySQL, otherwise there will be a lot of error messages later.
Yum install ncurses-devel libaio-devel-y
two。 Install the software cmake required for compiling MySQL (just yum directly)
Yum install cmake-y
Use cmake to compile MySQL
3. Create a MySQL user
Groupadd mysql-g 1002useradd mysql-u 1002-g 1002-s / sbin/nologin-M
MySQL data must be managed using mysql users and user groups
4.MySQL package installation
Download address: https://downloads.mysql.com/archives/community/
Community version-- > MySQL Community Server
5. Create a software download directory and a software installation path
Mkdir / server/tools-pmkdir / application-p
6. Download the mysql source code package and upload it to / server/tools
Cd / server/tools/ls mysql-5.7.20.tar.gz
7. Extract MySQL and compile and install
[root@db01 tools] # tar xf mysql-5.7.20.tar.gz [root@db01 tools] # cd mysql-5.7.20/ [root@db02 mysql-5.7.20] # cmake. -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.20\-DMYSQL_DATADIR=/application/mysql-5.7.20/data\-DMYSQL_UNIX_ADDR==/application/mysql-5.7.20/tmp/mysql.sock\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DMYSQL_TCP_PORT=3306\-DMYSQL_USER=mysql\-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_ARCHIVE_STORAGE_ ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITH_MEMORY_STORAGE_ENGINE=1\-DENABLE_DOWNLOADS=1\-DDOWNLOAD_BOOST=1\-DWITH_BOOST=/usr/local/boost [root@db01 mysql-5.6.36] # make & & make install compilation parameters explain:-DCMAKE_INSTALL_PREFIX # MySQL installation path-DMYSQL_DATADIR # storage path for MySQL data-DMYSQL_UNIX_ADDR # sock storage path after startup- Character set in DDEFAULT_CHARSET # MySQL database-DWITH_BOOST # mysql source code uses C++ 's Boost library-DENABLE_DOWNLOADS # such as boost path fill / usr/local/boost It will find it in this directory, and if it can't find it, it will download it to this directory.
MySQL compilation and installation will take a long time
Introduction to 8.MySQL catalogue
[root@db01 mysql-5.7.20] # tree-L 1 / application/mysql-5.7.20//application/mysql-5.7.20/ ├── bin # Storage mysql commands ├── COPYING ├── COPYING-test ├── docs # with help file ├── include ├── lib # lib library ├── man ├── mysql-test ├── README ├── README-test ├── share └── support-files
9. Configure and start MySQL
# 1. Create a soft connection [root@db01 /] # ln-s / application/mysql-5.7.20/ / application/mysql#2. Configuration / etc/my.cnf (version 5.7 does not come with my.cnf template file by default) [root@db01 /] # vim / etc/ my.cnf [mysqld] basedir=/application/mysqldatadir=/application/mysql/datasocket=/application/mysql/tmp/mysql.sockcharacter-set-server=utf8port=3306server_id=10log-error=/application/mysql/mysql.loglog-bin=/application/mysql/data/mysql-binbinlog_format=rowskip_name_ configuration [client] socket=/application/mysql/tmp/mysql.sock#3. Create / application/mysql/tmp directory to store mysql sock files, and set mysql directory permissions [root@db01 ~] # mkdir / application/mysql/tmp-p [root@db01 ~] # chown-R mysql.mysql / application/mysql/#4. Create the error log file [root@db01 ~] # touch / application/mysql-5.7.20/mysql.log#5. Initialization database (all initialization information is saved in the mysql log file, including the initialization root password) [root@db01 ~] # mkdir / application/mysql-5.7.20/data [root@db01 ~] # / application/mysql-5.7.20/bin/mysqld-- initialize-- user=mysql-- basedir=/application/mysql-5.7.20-- datadir=/application/mysql-5.7.20/data#6. Copy the mysql startup script to / etc/init.d/mysqld, which is used for mysql startup, restart and shutdown [root@db01 ~] # cp / application/mysql/support-files/mysql.server / etc/init.d/mysqld#7. Start the mysql database. The default port of mysql is 3306 [root@db01 ~] # / etc/init.d/mysqld start [root@db01 ~] # netstat-lntup | grep 3306 / 8. Add the mysql environment variable in order to execute the mysql command [root@db01 ~] # echo 'export "PATH=/application/mysql/bin:$PATH" > > / etc/profile [root@db01 ~] # tail-1 / etc/profile [root@db01 ~] # source / etc/profile [root@db01 ~] # echo $PATH directly on the command line
10. Obtain the root initialization password, and change the password to: 123456
[root@db01 /] # grep "temporary password" / application/mysql/mysql.log2019-01-14T03:22:24.841670Z 1 [Note] A temporary password is generated for root@localhost: HallelhbzsuPl1bind-[root@db01 /] # mysqladmin-uroot-p password "123456" Enter password: # enter the old password to change [root@db01 /] # mysql-uroot-p123456 # enter the new password to enter the database
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.