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--
The following mainly brings you MYSQL_Linux installation simple tutorial, I hope these text can bring you practical use, this is also my main purpose of editing MYSQL_Linux installation simple tutorial this article. All right, don't talk too much nonsense, let's just read the following.
* * Experimental environment * *
1. System platform: RedHat Linux 6.5
[root@mysql] # uname-a
Linux mysql 2.6.32-431.el6.x86_64 # 1 SMP Sun Nov 10 22:19:54 EST 2013 x86 "64 GNU/Linux
[root@mysql ~] # cat / etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel\ r on an\ m
two。 Practical software: mysql-5.5.37.tar.gz,cmake-2.8.12.2.tar.gz
Software source: http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/
Http://wwwNaNake.org/files/v2.8/
3. Pre-preparation work:
a. Modify the hostname file
[root@mysql /] # vi / etc/hosts
192.168.1.211 mysql
b. Modify the network configuration file
[root@mysql /] # vi / etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:A6:EF:6E
TYPE=Ethernet
UUID=4d0cd3ec-ef71-4036-bf9e-4d46ae76bcb2
ONBOOT=yes-- does not allow automatic boot
NM_CONTROLLED=yes
BOOTPROTO=static-- uses static IP addresses
IPADDR=192.168.1.221-- add Ip address
NETWORK=255.255.255.0-- add subnet mask
GATEWAY=192.168.1.1-- add Gateway
[root@mysql /] # service network restart
B. turn off the firewall
[root@mysql /] # service iptables stop
c. Turn off the security mechanism
[root@mysql /] # vi / etc/selinux/config
SELINUX=disabled
d. Restart the computer
[root@mysql /] # reboot
Or init 6
Or shutdown-rf
First, verify whether the installed library file exists in MYSQL. If it already exists, it needs to be deleted; otherwise, it will cause conflicts.
[root@mysql ~] # rpm-qa | grep-I mysql
Qt-mysql-4.6.2-26.el6_4.x86_64
Mysql-server-5.1.71-1.el6.x86_64
Mysql-libs-5.1.71-1.el6.x86_64
Perl-DBD-MySQL-4.013-3.el6.x86_64
Mysql-5.1.71-1.el6.x86_64
2. Uninstall existing MYSQL library files
[root@mysql] # rpm-ev qt-mysql-4.6.2-26.el6_4.x86_64-- nodeps
[root@mysql] # rpm-ev mysql-server-5.1.71-1.el6.x86_64-- nodeps
[root@mysql] # rpm-ev mysql-libs-5.1.71-1.el6.x86_64-- nodeps
[root@mysql] # rpm-ev mysql-5.1.71-1.el6.x86_64-- nodeps
[root@mysql] # rpm-ev perl-DBD-MySQL-4.013-3.el6.x86_64-- nodeps
OR uses yum to delete library files
/ * 6.5 yum configuration method * /
a. Backup system comes with Yum source, after backup; or delete or rename
[root@mysql mysql] # cp-p / etc/yum.repos.d/rhel-source.repo ~ / rhel-source.repo.bak
[root@mysql mysql] # rm-f / etc/yum.repos.d/rhel-source.repo
Or
[root@mysql mysql] # mv rhel-source.repo back_rhel-source.repo.bak
b. Create a yum source file
[root@mysql mysql] # cd / etc/yum.repos.d
Vi rhel6.repo
[rhel6.5]
Name=yum server
Baseurl= file:///yum
Enabled=1
Gpgcheck=0
Gpgfile= file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
c. Create a yum directory
[root@mysql mysql] # mkdir / yum
d. Hang it on the CD drive to the yum directory (after the redhat 6.5 configuration is complete, if you cannot identify the need to restart the CVM and mount the yum)
[root@mysql mysql] # mount / dev/cdrom / yum
f. Test the yum source
[root@mysql mysql] # Yum list
[root@mysql mysql] # Yum clean all
g. Delete MYSQL library files
[root@mysql mysql] # yum-y remove mysql-5.1.71-1.el6.x86_64
Third, load the dynamic function library into the cache to provide high availability of MYSQL
1. Write the directory of the MySQL database function library to this file
[root@mysql software] # vi / etc/ld.so.conf
Include ld.so.conf.d/*.conf
/ usr/local/lib
/ usr/local/lib64
two。 Save write, effective function library
[root@mysql software] # ldconfig
[root@mysql software] # ldconfig-p
4. Ensure that the following required system packages have been installed
1. Cut into the yum source storage directory
[root@mysql Packages] # cd / yum/Packages
two。 Gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*, a software package required for verification system
[root@mysql Packages] # rpm-qa | grep-I gcc*
3. Well, don't verify it all; install all the required packages
[root@mysql Packages] # yum-y install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*
5. there are two common installation methods, one is the source code installation with .tar format, and the other is the RPM package installation method.
* Source code package implements the installation process *
1. View MYSQL groups and users, rebuild MYSQL groups and users
[root@mysql ~] # cat / etc/group
[root@mysql ~] # cat / etc/passwd
[root@mysql ~] # userdel mysql
[root@mysql ~] # groupadd mysql
[root@mysql] # useradd-r-g mysql mysql
two。 Create a new working directory for MYSQL database. It is recommended to set it under / usr/local/.
a. Create MYSQL installation path
[root@mysql mysql] # mkdir-p / usr/local/mysql
b. Create a MYSQL database storage path
[root@mysql /] # mkdir-p / data/mysql
c. Give MYSQL data storage permission
[root@mysql /] # chown-R mysql:mysql / data/mysql/
[root@mysql /] # chmod 775 / data/mysql/
3. Install the cmake package
[root@mysql software] # tar-zxvf cmake-2.8.12.2.tar.gz
[root@mysql software] # ls
[root@mysql software] # cd cmake-2.8.12.2
[root@mysql cmake-2.8.12.2] # ls
[root@mysql cmake-2.8.12.2] #. / configure
[root@mysql cmake-2.8.12.2] # make;make install
4. Compile and install the MYSQL source package
[root@mysql software] # tar zxvf mysql-5.5.37.tar.gz
[root@mysql software] # cd mysql-5.5.37
[root@mysql mysql-5.5.37] # ls
[root@mysql mysql-5.5.37] # cmake. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/data/mysql/-DMYSQL_USER=mysql-DMYSQL_TCP_PORT=3306
[root@mysql mysql-5.5.37] # echo $?
* * Note * *
Echo $? If you return 0, you will be successful. If you return 1, you will fail.
When recompiling, you need to clear the old object files and cache information.
# make clean
# rm-f CMakeCache.txt
# rm-rf / etc/my.cnf
Parameter description:
-DCMAKE_INSTALL_PREFIX=/home/mysql/mysql / / installation directory
-DINSTALL_DATADIR=/home/mysql/data / / database storage directory
-DDEFAULT_CHARSET=utf8 / / use utf8 characters
-DDEFAULT_COLLATION=utf8_general_ci / / check character
-DEXTRA_CHARSETS=all / / install all extended character sets
-DENABLED_LOCAL_INFILE=1 / / allow data to be imported locally
[root@mysql mysql-5.5.37] # make;make install
[root@mysql mysql-5.5.37] # echo $? (0 indicates success, 1 indicates failure)
5. / directory structure under usr/local/src/mysql/mysql-5.5.37
Directory
Contents of Directory
Bin
Client programs and the mysqld server
Data
Log files, databases
Docs
Manual in Info format
Man
Unix manual pages
Include
Include (header) files
Lib
Libraries
Scripts
Mysql_install_db
Share
Miscellaneous support files, including error messages, sample configuration files, SQL for database installation
Sql-bench
Benchmarks
6. Configure and initialize the database
a. Create a my.cnf profile
[root@mysql mysql-5.5.37] # cp support-files/my-medium.cnf / etc/my.cnf
b. You need to assign the scripts/mysql_install_db file execution permission before execution
[root@mysql mysql-5.5.37] # cd / usr/local/mysql/
[root@mysql mysql] # ls
c. Initialize the database
[root@mysql mysql] # scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/data/mysql/
[root@mysql mysql] # echo $?
d. Create a shell script that manages the MySQL database and give it execution permissions
[root@mysql mysql] # cp support-files/mysql.server / etc/init.d/mysqld
[root@mysql mysql] # chmod + x / etc/init.d/mysqld
e. Start the MYSQL database
[root@mysql mysql] # / etc/init.d/mysqld start
Starting MySQL... [OK]
f. Log in to manage the MySQL CVM through the command line (enter directly when prompted for a password)
[root@mysql mysql] # / usr/local/mysql/bin/mysql-u root-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 1
Server version: 5.5.37-log Source distribution
Copyright (c) 2000, 2014, 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 > quit
Bye
g. Install the MYSQL client package to support MYSQL command line commands
[root@mysql Packages] # yum-y install mysql
h. Set Mysql password
[root@test] # / usr/local/mysql/bin/mysqladmin password-uroot 'cy_mysql'
* if you encounter a problem, you are prompted not to use a password * *
Mysqladmin: connect to server at 'localhost' failed
Error: 'Access denied for user' root'@'localhost' (using password: YES)'
* * solution * *
(1) check the use of passwords in configuration files
[root@mysql Packages] # cat / etc/my.cnf
(2) establish mysql command link
[root@mysql mysql] # ln-s / usr/local/mysql/bin/* / usr/local/bin
(3) start MYSQL in command line mode, change password, add remote connection capability to root, and update permissions
[root@mysql mysql] # mysqld_safe-- skip-grant-tables &
Mysql-uroot-p
Enter password:cy_mysql (enter password)
Mysql > use mysql
Mysql > GRANT ALL PRIVILEGES ON *. * TO root@ "%" IDENTIFIED BY "root"
Or
Mysql > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' cy_mysql' WITH GRANT OPTION
Mysql > update user set password=PASSWORD ("cy_mysql") where user= "root"
Mysql > select Host,User,Password from user where User='root'
Mysql > flush privileges
Mysql > quit
(4) restart the MYSQL database and verify the login
[root@mysql ~] # service mysqld restart
[root@mysql] # mysql-uroot-p
Enter password:cy_mysql
Mysql > show databases
+-+
| | Database |
+-+
| | information_schema |
| | mysql |
| | performance_schema |
| | test |
+-+
4 rows in set (0.00 sec)
Mysql > quit
7. Restart the Linux CVM and log in to MYSQL to report an error
[root@mysql] # mysql-uroot-p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket'/ data/mysql/mysql.sock' (2)
a. Check to see if the MYSQL data service starts
[root@mysql ~] # / etc/init.d/mysqld status
b. Start the MYSQL database
[root@mysql ~] # service mysqld start
Or
[root@mysql ~] # / etc/init.d/mysqld start
8. Use the Navicat for mysql tool to connect to MYSQL on the client side for operation
9. Modify command line undifferentiated table case in MYSQL CVM database
[root@mysql ~] # vi / etc/my.cnf
[mysqld]
Lower_case_table_names=1
10. Data backup and restore
(1)。 Back up the entire library
a. Create a backup directory
[root@mysql /] # mkdir / backup
b. Specify backup directory, specify backup library
[root@mysql /] # mysqldump-u root-p bank > / backup/test_bank.sql
Enter password:
c. Restore database
[root@mysql backup] # mysql-u root-p
Enter password:
Mysql > use bank
Database changed
Mysql > source / backup/test_bank.sql
(2)。 Back up a table
a. Backup tabl
[root@mysql backup] # mysqldump-u root-p bank tab_item > / backup/test_bank_item.sql
c. Restore table
[root@mysql backup] # mysql-u root-p
Enter password:
Mysql > use bank
Database changed
Mysql > source / backup/test_bank_item.sql
For the above simple tutorials on MYSQL_Linux installation, you do not find it very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.
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.