在亚马逊的Tokyo Region使用了个AWS EC2。
安装了Ubuntu 11.10的AMI之后,按照惯例安装各种软件, apache2.2, Mysql5.1。
在安装号mysqld启动的时候,发现如下错误:
[ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists!
原因:
在/etc/mysql/my.cnf的配置文件中,
#
# * IMPORTANT
# If you make changes to these settings and your system uses apparmor, you may
# also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
#
user = mysql
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
原来mysql server在启动的时候使用了mysql作为linux用户。
我们可以把配置文件中的 user=mysql 中的mysql改为当前我们正在使用的用户,比如我目前在用ubuntu用户, 这样就能解决问题。
当然还有另外一种办法。
我们先看看mysql这个用户到底在不在。
使用groups命令查看:
groups
ubuntu adm dialout cdrom floppy audio dip video plugdev netdev admin
很明显,不在嘛!
那我们就添加进去。
sudo groupadd -g 315 mysql
sudo useradd -u 315 -g mysql -d /var/lib/mysql -M mysql
启动mysql,sudo mysqld start。
但是又报错啦:
111210 13:24:46 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
111210 13:24:46 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
以上错误透露如下信息:
1.提示表不存在"Table 'mysql.plugin' doesn't exist"
2.可能是没有执行 mysql_install_db - u mysql 或 mysql_upgrade创建初始mysql数据库
而且启动选项中多了一个不支持的选项--skip-federated
那我们就执行下如下命令,看能否解决上述问题:
sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql
Neither host 'ip-10-146-22-118' nor 'localhost' could be looked up with
/usr/bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
以前的问题还没有解决,又来新问题啦。。。
Google搜索下,搜到了以下链接的文章:
http://blog.chinaunix.net/space.php?uid=259788&do=blog&id=2139245
试了各种办法,都没法解决,包括修改hosts文件,最后只能强制执行了。
(后来我发现,其实只要将/etc/hostname文件中的内容ip-10-146-22-118给修改为127.0.0.1就行了。)
sudo mysql_install_db --user=mysql --datadir=/var/lib/mysql --force
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h ip-10-146-22-118 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/scripts/mysqlbug script!
还好,算是成功了。
等等!!
我这边已经是晚上11点了,系统上怎么显示的是下午一点呢!
难道东京亚马逊的AWS没有给俺设定好时区?
查看下:
date -R
Sat, 10 Dec 2011 13:50:00 +0000
果然,我这边是东9区。它竟然给我弄个0区。
先搜索如何修改:
http://www.xgdown.com/article/53/142110_1.htm
再修改之:
sudo cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
sudo ntpdate jp.pool.ntp.org
jp.pool.ntp.org是位于日本的公共NTP服务器,用来同步系统时间。
关于全球各地的NTP服务器,可以参考这里:
http://www.pool.ntp.org/zone/@
成功修改时间。
不好意思,跑题了。。。
接下来继续启动Mysql Server,靠,还有错!
sudo mysqld restart
111210 23:39:04 [Note] Plugin 'FEDERATED' is disabled.
111210 23:39:04 InnoDB: Initializing buffer pool, size = 8.0M
111210 23:39:04 InnoDB: Completed initialization of buffer pool
111210 23:39:04 InnoDB: Started; log sequence number 0 44233
mysqld: Too many arguments (first extra is 'restart').
Use --verbose --help to get a list of available options
111210 23:39:04 [ERROR] Aborting
111210 23:39:04 InnoDB: Starting shutdown...
111210 23:39:09 InnoDB: Shutdown completed; log sequence number 0 44233
111210 23:39:09 [Note] mysqld: Shutdown complete
继续Google搜索答案,尝试如下方法:
sudo chown mysql:mysql /var/lib/mysql/ -R
sudo chmod g+rw /var/lib/mysql/ -R
sudo /usr/sbin/mysqld --skip-grant &
还是出错:
sudo mysqld
111211 0:40:54 [Note] Plugin 'FEDERATED' is disabled.
111211 0:40:54 InnoDB: Initializing buffer pool, size = 8.0M
111211 0:40:54 InnoDB: Completed initialization of buffer pool
111211 0:40:54 InnoDB: Started; log sequence number 0 44233
111211 0:40:54 [ERROR] Can't start server : Bind on unix socket: No such file or directory
111211 0:40:54 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?
111211 0:40:54 [ERROR] Aborting
111211 0:40:54 InnoDB: Starting shutdown...
111211 0:40:59 InnoDB: Shutdown completed; log sequence number 0 44233
111211 0:40:59 [Note] mysqld: Shutdown complete
没有写目录的权限。就给它写的权限:
sudo chmod 777 /var/run/mysqld/
再次运行 sudo mysqld &, 成功启动。
但是登陆的时候又出问题!
E
RROR 1045 (28000): Access denied for user ''@'localhost' (using password: NO)
解决办法:
1,先停止mysqld服务, 注意,u,p后没有空格
sudo mysqladmin -uroot -ppassword shutdown
2,通过以下方式启动Mysql Server
sudo mysqld --skip-grant &
3,输入mysql命令,进入,然后执行以下语句。
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> \q
4,再次启动Mysql Server。
sudo mysqld &
5,使用以下命令登陆Mysql数据库:
mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.1.58-1ubuntu1 (Ubuntu)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
终于成功。
真折腾人啊,每次重新弄个环境,就要花费好长时间折腾这些玩意儿。
下面的内容挺有用的,分享下链接:
http://www.cnblogs.com/wuhou/archive/2008/09/28/1301071.html
分享到:
相关推荐
主要介绍了解决ubuntu vps安装docker时报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock.问题的相关资料,文中介绍非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
vsftp出现550 Failed to change directory Ubuntu 获取软件失败 404错误 解决Ubuntu提示500 OOPS: vsftpd: refusing to run with writable root inside chroot()
最近在linux连接mysql /usr/local/mysql/bin/mysql -uroot -p 输入密码出现Access denied for user 'root'@'localhost'(using password: YES)错误。下面话不多说了,来一起看看详细的解决方法吧 解决办法: 1.先停止...
我安装的子系统是Ubuntu 1804,安装docker步骤如下: sudo apt update // 更新软件源 sudo apt install -y docker.io // 安装docker sudo usermod -aG docker leo // 添加当前用户leo到docker用户组,然后重启WSL,...
1. 通过终端安装程序sudo apt-get install ***时出错: 2. 安装Gnome3, 3. Ubuntu11.04和11.10 在安装VMWare Tools遇到的问题
wsl-update,用于windows中Ubuntu子系统报错解决
最近在学习Django框架,于是在windows系统上搭建了Django环境,并使用虚拟机ubuntu系统上安装的mysql作为项目的远程数据库,前几天一直用得好好的,今天在虚拟机上连接数据库时,出现了如下错误: 本地数据库没法...
Ubuntu8.10下mysql是自启动的,但root用户、mysql数据库都被限制了。该Shell脚本是启动mysql安全模式脚本,启动后mysql数据库可以自行调试。比如php、lighttp、mysql。
*******@ubuntu:/opt/mysql$ sudo dpkg -i mysql-community-client_5.7.21-1ubuntu14.04_amd64.deb Selecting previously unselected package mysql-community-client. (Reading database ... 208518 files and ...
列举了一些Linphone编译错误及解决办法,给有需要的人,只是我遇到的错误,可能不全面。
Ubuntu 通过国内的镜像源安装 MySQL ,可以安装 MySQL 5.7 和 MySQL8.0 ,以及更新到最新版本。
当前系统Ubuntu16 shell进行字符串截取 运行 ${GIT_COMMIT:0:6}报错: /tmp/jenkins7505855461406722507.sh: 4: /tmp/jenkins7505855461406722507.sh: Bad substitution 原因:两种shell语言解释器 bash和dash ...
mongodb 命令行mongod启动报错 about to fork child process, waiting until server is ready for connections. forked process: 3560 ERROR: child process failed, exited with error number 1 To see additional ...
libmysqld-dev_5.7.25-1ubuntu16.04_amd64.deb,mysql-client_5.7.25-1ubuntu16.04_amd64.deb,mysql-common_5.7.25-1ubuntu16.04_amd64.deb,mysql-community-client_5.7.25-1ubuntu16.04_amd64.deb,mysql-...
ubuntu报错:libg2c.so.0:cannot open shared object file: no such file or directory/wrong ELF class(已解决)-附件资源
ubuntu安装SSH报错解决,原创文章
在Ubuntu上离线安装mysql5.7.25。完整安装包(含三个依赖包)
Django开发项目时使用MySQL数据库,然而部署到Ubuntu服务器的时候会经常出错。 Django连接MySQL数据库需要依赖第三方库mysqlclient,然而服务器通过pip3 install mysqlclient 命令安装第三方库mysqlclient时会经常...