Preface
This blog post was previously written and is not very professional in some places. Let's take a look at it. Of course, it is not a problem to install MySQL by following the steps.
Installation environment description:
System: Ubuntu 11.10
MySQL: MySQL 5.5.17
1. Try it under root
The main reason is that my permissions for common users are too large.
1.1 install MySQL
Here are the answers in the installation instructions:
to install and use a MySQL binary distribution, the basic command sequence looks like this: shell> groupadd MySQL shell> useradd-r-g MySQL shell> Cd/usr/local shell> tar zxvf/path/to/mysql-VERSION-OS.tar.gz shell> ln-s full-path- -mysql-version-OS MySQL shell> Cd MySQL shell> chown-r MySQL. shell> chgrp-r MySQL. shell> scripts/msql_install_db -- user = MySQL shell> chown-r root. shell & gt; chown-r Mysql Data # next command is optional shell & gt; CP support-files/my-medium.cnf/etc/My. CNF shell> bin/mysqld_safe -- user = MySQL & # next command is optional shell> CP support-files/MySQL. server/etc/init. d/MySQL. server
After many attempts by common users, the database cannot be started. Therefore, I switched to the root user for installation,
Prompt: By default, UBUNTU does not have a password, so you cannot log on. Under the current user, enter sudo passwd root in the terminal.Enter the logon password of the current user, and set the root user password.
Command record attached:
CD/etc RM my. CNF Rm-RF MySQL/CD/find-name "MySQL"-print CD/etc/apparmor. d/export actions/Rm-RF MySQL
The above command is because MySQL has been installed and some junk files are left behind. Search for them and delete them all.
Groupadd MySQL useradd-r-g MySQL CD/usr/local cd src ln-S/usr/local/src/mysql-5.5.17-linux2.6-i686/MySQL CD MySQL chown-r MySQL. chgrp-r MySQL. scripts/mysql_install_db -- user = MySQL chown-r root. chgrp-r MySQL. chown-r root. chown-r Mysql Data LS-l bin/mysqld_safe -- user = MySQL &
A series of problems may have occurred since there is no chown-r Mysql Data. If you do not know the root cause, record it first. After the command is executed, the command line returns a process number, prompting the MySQL process to start,No error is reported.. This proves that MySQL is started.
1.2 Test Service
Open a new terminal and perform the following operations:
/Usr/local/MySQL/bin/mysqladmin version
Normally, the following is returned:
Root @ air :~ #/Usr/local/MySQL/bin/mysqladmin version
/Usr/local/MySQL/bin/mysqladmin ver 8.42 distrib 5.5.17, for linux2.6 on i686
Copyright (c) 2000,201 1, 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.
Server version 5.5.17
Protocol version 10
Connection
Localhost via UNIX socket
UNIX socket
/Tmp/MySQL. Sock
Uptime:
1 min 5 sec
Threads: 1 questions: 1 Slow queries: 0 opens: 33 flush tables: 1 open tables: 26 queries per second AVG: 0.015
1.3 configure Parameters
Next, copy the default configuration file to the/etc folder and name it my. CNF. The command is as follows:
CD/usr/local/mysqlcp support-files/my-medium.cnf/etc/My. CNF
Now we are ready to start the service. You can start it:
Bin/MySQL-u root-P
If it is normal, the following is returned:
Root @ air:/usr/local/MySQL # bin/MySQL-u Root
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 2
Server version: 5.5.17 MySQL Community Server (GPL)
Copyright (c) 2000,201 1, 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>
# Enter \ s to check the status and exit \ Q.
1.4 Security Configuration
Now we have started the service, but the password is not set. Next we can run the following command:
Root @ air:/usr/local/MySQL # bin/mysql_secure_installation
, in fact, you can manually set the password, delete the test database, and perform operations such as anonymous users according to the two statements in the install-binary file. (in terms of security, you must perform the preceding operations) however, we recommend that you use the preceding statements to set them together.
Note: running all parts of this script is recommended for all MySQL servers in production use! Please read each step carefully! In order to log into MySQL to secure it, we'll need the currentpassword for the root user. if you 've just installed MySQL, andyou haven' t set the root password yet, the password will be blank, so you shoshould just press enter here. enter current password for root (enter for none): Error 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: Yes) enter current password for root (enter F Or none): Error 1045 (28000): Access denied for user 'root' @ 'localhost' (using password: Yes) Enter current password for root (enter for none): OK, successfully used password, moving on... setting the root password ensures that nobody can log into the mysqlroot user without the proper authorisation. set root password? [Y/n] ynew password: re-enter new password: Password updated successfully! Reloading privilege tables... success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. this is intended only for testing, and to make the installation go a bit smoother. you shoshould remove them before moving into a production environment. remove anonymous users? [Y/n] y... success! Normally, root shoshould only be allowed to connect from 'localhost'. thisensures that someone cannot guess at the root password from the network. disallow root login remotely? [Y/n] y... success! By default, MySQL comes with a database named 'test' that anyone caaccess. this is also intended only for testing, and shocould be removedbefore moving into a production environment. remove test database and access to it? [Y/n] Y-dropping test database... error 1010 (hy000) at line 1: Error dropping database (can't rmdir '. /test/', errno: 17 )... failed! Not critical, keep moving...-removing privileges on test database... success! Reloading the privilege tables will ensure that all changes made so farwill take effect immediately. Reload privilege tables now? [Y/n] y... success! Cleaning up... all done! If you 've completed all of the above steps, your MySQL installation shoshould now be secure. Thanks for using MySQL!
2. environment variables and auto-start
2.1 configure Environment Variables
However, we find that the absolute path is basically required for every command run, or run bin/### in the installation directory /###. #. If apt-Get is used for installation, this problem will not occur, mainly for installation. Program You have already done it for you. In this case, we set the environment variable to solve this problem. Similar to configuring the JDK environment in windows, we need to set the Java command path. In ubuntu, the environment variable can be set to user-level or system-level, the difference is that it takes effect for a single user or global user, for bash or other users. I am also new to this, listing the following operation procedures and methods. I use system-level variables:
System environment variables are generally stored in the following files:
/Etc/environment
/Etc/profile
/Etc/bash. bashrc
/Etc/profile and/etc/bash. bashrc are not recommended in Ubuntu 10.0.
To add a path to $ path, perform the following operations (modify/etc/profile ):
$ Sudo nano/etc/profile
Add the following statement:
Export Path = "$ path:/my_new_path"
You can add multiple specified paths separated by colons. After the environment variable is changed, it will take effect the next time the user logs in. If you want to take effect immediately, you can execute the following statement:
$ Source/etc/profile
Note that it is best not to put the current path "./" in the path, which may be subject to unexpected attacks.
Other files are modified in a similar way. Note that you do not need to use export to set environment variables for/etc/environment.
In this way, all the terminals under the user know the commands under/usr/local/MySQL/bin.
2.2 configure auto-start
It can be started as follows:
/Usr/local/MySQL/bin/mysqld // start the MySQL service/usr/local/MySQL/bin/MySQL-u root // access the MySQL server/usr/local/MySQL/ bin/mysqladmin-u root-P shutdown // close the MySQL server
It is best to make it run in the background:
/Usr/local/MySQL/bin/mysqld &
Enable Automatic Service Startup
CP/usr/local/MySQL/support-files/My. Server/etc/init. d/mysqldsudo update-rc.d mysqld default
Add mysqld to the service and restart the machine.
Of course, you can directly enter
/Etc/init. d/mysqld restart | start
At this point, the installation of MySQL has basically been completed.
Several Common Errors:
Common error 1:
The first installation with the permissions of a common user may be successful due to permission issues and the loss of an operation step. However, the following error is reported during each startup:
Air @ air:/usr/local/MySQL/bin $ sudo/usr/local/MySQL/bin/mysqld_safe -- user = MySQL & [1] 6379air @ air: /usr/local/MySQL/bin $111116 11:58:56 mysqld_safe logging to '/var/log/MySQL/error. log '. touch: Unable to create "/var/log/MySQL/error. log ": no such file or directory chown: inaccessible"/var/log/MySQL/error. log ": there is no such file or directory 111116 11:58:56 mysqld_safe starting mysqld daemon with databases from/var/lib/MySQL/usr/local/MySQL/bin/mysqld_safe: 107: /usr/local/MySQL/bin/mysqld_safe: cannot create/var/log/MySQL/error. log: Directory nonexistent/usr/local/MySQL/bin/mysqld_safe: 1: Eval: cannot create/var/log/MySQL/error. log: Directory nonexistent1116 11:58:57 mysqld_safe mysqld from PID file/var/lib/MySQL/air. PID ended
From the above, it should be the problem of setting data users and user groups in the MySQL installation folder, because this is the only operation that I did not do, and may cause a series of permissions problems.
As for the so-called. PID file, it does not need to be created. This and. Sock files are automatically created dynamically. It is suspected that the MySQL user is used, but the attribute is changed to the current user air, resulting in this problem.
I hope you can give me some advice.
Common Error 2:
Air @ air:/usr/local/MySQL $ scripts/mysql_install_db -- user = MySQL fatal error: cocould not find mysqld the following directories were searched: /usr/libexec/usr/sbin/usr/binif you compiled from source, you need to run 'make install' to copy the software into the correct location ready for operation. if you are using a binary release, you must either be at the top level of the extracted archive, or pass the -- basedir option pointing to that low.o
Solution: this problem is obvious. For binary installation, you must install it in the/usr/local folder. You can decompress the package in another folder, (It is best to set up a link under/usr/local/src for ease of management.) You must set up a link under/usr/local to point to your source Binary Package.
Command: ln-S/usr/local/src/MySQL-version MySQL unzip: sudo tar zxvf/path/to/Your/source.tar.gz
FAQ 3:
Air @ air:/usr/local/MySQL $ sudo scripts/mysql_install_db -- user = MySQL -- basedir =/usr/local/MySQL installing MySQL system tables... /usr/local/MySQL/bin/mysqld: Error while loading shared libraries: libaio. so.1: cannot open shared object file: no such file or directory installation of system tables failed! Examine the logs in/var/lib/MySQL for more information. you can try to start the mysqld daemon: shell>/usr/local/MySQL/bin/mysqld -- skip-grant & and use the command line tool/usr/local/MySQL/bin/MySQL to connect to the MySQL database and look at the grant tables: shell>/usr/local/MySQL/bin/MySQL-u root MySQL mysql> show tablestry 'mysqld -- help' if you have problems with paths. using -- l OG gives you a log in/var/lib/MySQL that may be helpful. please consult the MySQL Manual section 'problems running mysql_install_db ', and the Manual section that describes problems on your OS. another information source are the MySQL email archives available at http://lists.mysql.com/.Please check all of the above before mailing us! And remember, if you do mail us, you must use the/usr/local/MySQL/scripts/mysqlbug script!
After you solve the above installation folder, you will often encounter the above problems, if you have not updated the library after installing Ubuntu or install and run the support library.
This file libaio. so.1 is missing. You can search the file online, or you can search for the new file or the Software Center,
You must install the following package:
Libaio1 0.3.109-2ubuntu1,
No error is reported after the following installation.
Thank you for your patience.