尝试手动安装时出现以下错误mysql-5.6.17-linux-glibc2.5-x86_64
我遵循的步骤:
1. tar -xzvf mysql-standard-5.1.34-linux-i686-glibc23.tar.gz
2. ln -s mysql-standard-5.1.34-linux-i686-glibc23 mysql
a) set basedir= to the full path of your new mysql directory
b) set datadir= to the full path of the /data subdir in your new mysql directory.
3. Set up the default MySQL databases:
a) ./scripts/mysql_install_db --defaults-file=mysql.cnf
b) ./bin/mysqladmin --defaults-file=mysql.cnf -u root password "yourpasswordhere"
4. Create a New Database and User Account
a) Log in to your mysql server as root: ./bin/mysql --defaults-file=mysql.cnf -u root -p
mysql.cnf 文件如下所示:
[client]
socket=/tmp/mysql_2.sock
port=3307
####################################
[mysqld]
#REQUIRED!!
#Change the basedir directory to reflect your mysql home directory
basedir=/mysql
#REQUIRED!!
#Change the data direcory to reflect your mysql data directory
datadir=/mysql/data
port=3307
socket=/tmp/mysql_2.sock
key_buffer_size=64M
#[OPTIMIZATION]
#Set this value to 50% of available RAM if your environment permits.
myisam_sort_buffer_size=1.5G
#[OPTIMIZATION]
#This value should be at least 50% of free hard drive space. Use caution if setting it to 100% of free space however. Your hard disk may fill up!
myisam_max_sort_file_size=100G
#[OPTIMIZATION]
#Our default of 2G is probably fine for this value. Change this value only if you are using a machine with little resources available.
read_buffer_size=1.5G
命令:
root@ubuntu:/mysql# ./bin/mysqld_safe --defaults- file=mysql.cnf &
错误:
[1] 2386
root@ubuntu:/mysql# 140415 19:08:12 mysqld_safe Logging to '/mysql/data/ubuntu.err'.
chown: invalid user: `mysql'
140415 19:08:12 mysqld_safe Starting mysqld daemon with databases from /mysql/data
140415 19:08:12 mysqld_safe mysqld from pid file /mysql/data/ubuntu.pid ended
./bin/mysqladmin --defaults-file=mysql.cnf -u
./bin/mysqladmin --defaults-file=mysql.cnf -u root password 12345
./bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql_2.sock' exists!
[1]+ Done ./bin/mysqld_safe --defaults-file=mysql.cnf
我尝试通过命令登录:
./bin/mysql --defaults-file=mysql.cnf -u root -p
错误:
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql_2.sock' (2)
答案1
你应该:
- 为你的 mysql 服务器添加一个用户
useradd -r -s /bin/false -m -d /mysql mysql
- 写一个暴发户您的服务器的脚本。
- 通过执行正确的,检查用户是否
pid
可以创建文件和套接字文件。mysql
chmod
答案2
手动执行时,有几个步骤需要检查,可能会导致上述错误。我假设您从官方网站手动下载了 MySQL,或者使用第三方 PPA 来安装它:
检查 mysql 是否尚未运行:
ps -e|grep -i 'mysqld'
。如果它出现了,那么你需要通过 来杀死它
sudo killall -9 mysqld
。如果它没有死掉,那么从ps
你运行的程序中获取 PID 并kill -9 PID
通过运行 mysql
/etc/init.d/mysql start
来查看是否会产生相同的错误。如果它给出与上述完全相同的错误,则需要复制mysql.server
您下载的 mysql 文件夹内的 support-files 文件夹或文件夹中的文件,/usr/local/mysql
并将其复制到/etc/init.d/mysql
例如:cp mysql.server /etc/init.d/mysql
并赋予它可执行权限 chmod +x 然后尝试/etc/init.d/mysql start
再次运行。如果仍然有问题,则需要编辑配置文件,
/etc/my.cnf
将所有行更改/tmp/mysql.socket
为/var/run/mysqld/mysqld.sock
或您希望发送的任何其他套接字位置。请注意,/etc/mysql/my.cnf
在某些情况下,配置文件也可以位于,例如我的情况。配置文件至少有 3 行需要更改。
答案3
如果你的文件 my.cnf(通常在 /etc/mysql/ 文件夹中)已正确配置
socket=/var/lib/mysql/mysql.sock
您可以使用以下命令检查 mysql 是否正在运行:
mysqladmin -u root -p status
更改对 mysql 文件夹的权限。如果您在本地工作,您可以执行以下操作:
sudo chmod -R 755 /var/lib/mysql/