Install mysql rpm package

Source: Internet
Author: User
Tags mysql host

Mysql rpm package installation mysql Oracle official Download type exclusive looks a headache we choose to Download MySQL Community Server http://dev.mysql.com/downloads/mysql/ In this download site selection platform is mozl & red hat liunx 5 Select installation package MySQL-5.6.12-1.linux_glibc2.5.x86_64.rpm-bundle 303M in windows decompress it contains the SERVER and CLIENT words of the two files uploaded to linux go to I upload/home directory and then root user rpm-ivh mysql-service-5.6.12 -....... the rpm packages are successfully installed. Mysql-u rooterror 1045 (28000): access denied for user 'root' @ 'localthost' (using password: NO) [root @ loaclhost]/usr/bin/mysqld_safe -- usr = mysql -- skip-grant-tables -- skip-networking & enable the second terminal [root @ loaclhost]/usr/bin/ mysql-u root mysql finally enters mysql> update user set password = password ('yourword ') where user = 'root'; mysql> flush PRIVILEGES; mysql> quit [root @ loaclhost] service mysql restart [Root @ loaclhost]/usr/bin/mysql-uroot-p successfully entered directory 1, database directory/var/lib/mysql/2, configuration file/usr/share/mysql (mysql. server commands and configuration files) 3. Related commands/usr/bin (mysqladmin mysqldump and other commands) 4. STARTUP script/etc/rc. d/init. d/(directory for starting the script file mysql) 7. Change the MySQL directory to/var/lib/MySQL by default. To move the directory to/home/data, perform the following steps: 1. Create the data DIRECTORY cd/opt mkdir mysql_rpm_5612/data/Under the opt directory and stop the MySQL service process: mysqladmin-u root-p shutdown 3. Move the entire/var/lib/mysql directory to/opt/mysql_rpm_5612/data/mv/var/lib/mysql/opt/mysql_rpm_5612/data/ in this way, the MySQL data file is moved to/home/data/mysql 4. Find my. if the cnf configuration file does not exist in the/etc/directory. for the cnf configuration file, go to/usr/share/mysql/and find *. copy one of the cnf files to/etc/and change it to my. cnf. Command: [root @ test1 mysql] # cp/usr/share/mysql/my-medium.cnf/etc/my. cnf 5. Edit the MySQL configuration file/etc/my. to ensure that MySQL works properly, cnf must specify mysql. the location where the sock file is generated. Change socket =/var/lib/mysql. sock to/home/mysql. sock. The operation is as follows: vi my. cnf (use vi tool to edit my. cnf file, find The following data to modify) # The MySQL server [mysqld] port = 3306 # socket =/var/lib/mysql. sock (original content, to make it more secure to use "#" to comment out this line) socket =/opt/mysql_rpm_5612/data // mysql/mysql. sock (add this line) 6. Modify the MySQL STARTUP script/etc/rc. d/init. d/mysql, You need to modify the MySQL STARTUP script/etc/rc. d/init. d/mysql: change the path on the Right of datadir =/var/lib/mysql to your actual storage path: home/data/mysql. [Root @ test1 etc] # vi/etc/rc. d/init. d/mysql # datadir =/var/lib/mysql (comment this row) datadir =/opt/mysql_rpm_5612/data // mysql (add this row) 7. Restart the MySQL service/etc/rc. d/init. d/mysql start or use the reboot command to restart Linux. If it moves normally, it will be successful. Otherwise, check the previous 7 steps and check the localhost in the directory. localdomain. err found: Can't start server: Bind on unix socket: Permission deniedDo you alread have another mysqld server running on socket:/opt/mysql_rpm_5612/data/mysql. sock? I realized that/etc/my. cnf was wrong. Server mysl start OK mysql-u root-penter password: Error 2002 (HY000): can't connect to local mysql server through socket '/var/lib/mysql. sock (2) 'mysql-u root-p is the client segment software package so in/etc/my. cnf added [client] socket =/opt/mysql_rpm_5612/data // mysql/mysql. sock log on again: mysql-u root-penter password: Okmysql> show databases; ERROR 1820 (HY000): You must set password before executing this statement. It's very strange to log on with your password. Why do I still ask for a password. For more information, see http://dev.mysql.com/doc/refman/5.6/en/alter-user.html . After the following operations, it will be OK: mysql> create database yan1; ERROR 1820 (HY000): You must SET PASSWORD before executing this statementmysql> SET PASSWORD = PASSWORD ('123 '); query OK, 0 rows affected (0.03 sec) mysql> create database yan1; Query OK, 1 row affected (0.00 sec) that is, use mysql> set password = PASSWORD ('123'); in this case, reset the PASSWORD! It's really hard. This dear friend also encountered the same problem. Mysql> show databases; display Database mysql> show databases; + ---------- + | Database | + ---------- + | mysql | test | + ---------- + 2 rows in set (0.04 sec) mysql has just been installed with two databases: mysql and test. The mysql database is very important. It contains MySQL system information. We change the password and add new users. In fact, we use the relevant tables in this database for operations. 2. display the table mysql> use mysql in the Database. (To open the Database, you must open this Database for each Database operation, similar to foxpro) Database changed mysql> show tables; + ----------------- + | Tables_in_mysql | + ----------------- + | columns_priv | db | func | host | tables_priv | user | + ----------------- + 6 rows in set (0.01 sec) 3. display the structure of the data table: describe table name; 4. display the record in the Table: select * from table name; for example, display the records in the user table in the mysql database. All users who can operate on MySQL users are in this table. Select * from user; 5. database creation: create database name; for example, create a database named aaa mysql> create databases aaa; 6. Table creation: use database Name; create table name (field setting list). For example, create a table name in the newly created aaa database. The table has IDS (sequence numbers, auto-increment), xm (name ), xb (gender), csny (date of birth) four fields use aaa; mysql> create table name (id int (3) auto_increment not null primary key, xm char (8 ), xb char (2), csny date); you can use the describe command to view the created table structure. Mysql> describe name; + ------- + --------- + ------ + ----- + --------- + ---------------- + | Field | Type | Null | Key | Default | Extra | + ------- + --------- + ------ + ----- + --------- + ---------------- + | id | int (3) | PRI | NULL | auto_increment | xm | char (8) | YES | NULL | xb | char (2) | YES | NULL | csny | date | YES | NULL | + ------- + --------- + ------ + ----- + --------- + ---------------- + 7 Add records, for example, add several related records. Mysql> insert into name values ('', 'zhang san', 'mal', '2017-10-01 '); mysql> insert into name values ('', 'baiyun ', 'femal', '1970-05-20 '); Use the select command to verify the result. Mysql> select * from name; + ---- + ------ + ------------ + | id | xm | xb | csny | + ---- + ------ + ------------ + | 1 | Zhang San | male | 1971-10-01 | 2 | Baiyun | female | 1972-05-20 | + ---- + ------ + ------------ + 8. Modify the record for example: change the date of birth of Michael Jacob to 1971 mysql> update name set csny = '2017-01-10 'where xm = 'zhang san'; 9. delete a record, for example, delete Michael Jacob's record. Mysql> delete from name where xm = 'zhang san'; 10. database deletion and table deletion drop database name; drop table name; 9. MySQL user format added: grant select on database. * to username @ login host identified by "password" Example 1. Add a user user_1 with a password of 123 so that he can log on to any host, all databases are permitted to query, insert, modify, and delete databases. First, use the root user to connect to MySQL, and then type the following command: mysql> grant select, insert, update, delete on *. * to user_1 @ "%" Identified by "123"; in Example 1, it is very dangerous to add users. If you know the user_1 password, then he can log on to your MySQL database on any computer on the Internet and do whatever he wants. For the solution, see Example 2. Example 2: Add a user_2 password of 123 so that the user can only log on to localhost, you can also query, insert, modify, and delete the database aaa (localhost refers to the local host, that is, the host where the MySQL database is located), so that the user knows the password of user_2, he cannot directly access the database from the Internet, and can only operate the aaa database through the MYSQL host. Mysql> grant select, insert, update, delete on aaa. * to user_2 @ localhost identified by "123"; if a new user cannot log on to MySQL, run the following command during logon: mysql-u user_1-p-h 192.168.113.50 (-h followed by the IP address of the host to be logged on) 10. backup and recovery 1. Backup example: back up the aaa database created in the previous example to the file back_aaa [root @ test1 root] # cd/home/data/mysql (go to the database directory, in this example, the database has been transferred from val/lib/mysql to/home/data/mysql. For details, see section 7) [root @ test1 mysql] # mysqldump-u root-p -- opt aaa> back_aaa 2. Restore [root @ test mysql] # mysql-u root-p ccc <back_aaa

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.