How to Start fedora16yum after mysql is installed and add it as the system service Fedora
BitsCN.com
Fedora 16 yum how to start mysql after installation and add it as a system service
1 yum install mysql
# Yum install mysql-server mysql-devel
If ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var
You can use the following command:
Start mysql service
# Systemctl start mysqld. service
Set mysqld to auto-start
# Systemctl enable mysqld. service
2. usage of systemctl
This command is a system Process Management Command. the comparison table uses apache/httpd as an example.
New commands of old task commands
Enable a service to automatically start chkconfig -- level 3 httpd on systemctl enable httpd. service
So that a service does not automatically start chkconfig -- level 3 httpd off systemctl disable httpd. service
Check service status service httpd status systemctl status httpd. service (service details) systemctl is-active httpd. service (only show whether it is Active)
Show all started services chkconfig -- list systemctl list-units -- type = service
Start a service httpd start systemctl start httpd. service
Stop a service httpd stop systemctl stop httpd. service
Restart a service httpd restart systemctl restart httpd. service
3. after installation, you can view the installation location of the corresponding mysql command.
Find the installation location of the mysql server file
# Rpm-ql mysql-server
Find the installation location of the mysql client file
# Rpm-ql mysql
4. the mysql management database is not installed by default. run the installation command.
# Mysql_install_db
Or add parameters.
# Mysql_install_db -- user = root -- basedir =/usr -- datadir =/var/lib/mysql
After installing mysql to manage the database, you can start mysql. you can view the values of basedir and datadir.
Start mysql
# Mysqld_safe -- user = root &
Find the process ID of mysqld
# Ps aux | grep mysqld
End mysqld. The process number is obtained by the preceding command. Note that the process Number of/usr/bin/mysqld is not the process Number of/bin/sh/usr/bin/mysqld_safe.
# Killed 35431
5. download the support-files/mysql. server file in a mysql Linux binary compression installation package (the version number is similar to 5.5.xx) and modify the two lines.
Basedir =/usr
Datadir =/var/lib/mysql
Search for the 'start' segment and change $ bindir/mysqld_safe -- datadir = "$ datadir" to $ bindir/mysqld_safe -- user = root -- datadir = "$ datadir ".
Then
# Cp mysql. server/etc/rc. d/init. d/mysqld
# Chmod + x/etc/rc. d/init. d/mysqld
So far, mysql is successfully registered as a service. you can use the # service mysqld start | stop | restrat command to run mysql.
Start mysql
# Service mysqld start
Add password 123 to the root user of mysql
# Mysqladmin-u root password 123
Use the mysql command line client
# Mysql-u root-p 123
6. startup of mysqld. service fails.
The following error occurs when you start a service using service mysqld start:
Redirecting to/bin/systemctl start mysqld. service
Failed to issue method call: Access denied
The following error occurs when systemctl is used to start mysql. service:
Failed to issue method call: Unit mysql. service failed to load: No such file or directory. See system logs and 'systemctl status mysql. service' for details.
Directly input mysql with the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock' (2)
Solution: The owner of mysql is root, while mysql cannot be written as a mysql User, which is a problem of system permissions. chown-R mysql: mysql/var/lib/mysql /.
BitsCN.com