MySQL 时区默认是服务器的时区。
可以通过以下命令查看
- mysql> show variables like '%time_zone%';
- +------------------+--------+
- | Variable_name | Value |
- +------------------+--------+
- | system_time_zone | CST |
- | time_zone | SYSTEM |
- +------------------+--------+
- 2 rows in set (0.00 sec)
可以通过修改my.cnf
在 [mysqld] 之下加
default-time-zone=timezone
来修改时区。如:
default-time-zone = '+8:00'
改了记得重启msyql喔
注意一定要在 [mysqld] 之下加 ,否则会出现 unknown variable 'default-time-zone=+8:00'
另外也可以通过命令 set time_zone = timezone
比如北京时间(GMT+0800)
set time_zone = '+8:00';
这个和php的时区设置又有点差别,比如北京时间在php中是
date_default_timezone_set('Etc/GMT-8');
美国pst时间(GMT-08:00)
set time_zone = '-8:00';
- mysql> set time_zone = '+8:00';
- Query OK, 0 rows affected (0.00 sec)
- mysql> select now();
- +---------------------+
- | now() |
- +---------------------+
- | 2008-12-29 11:26:36 |
- +---------------------+
- 1 row in set (0.00 sec)
- mysql> set time_zone = '-8:00';
- Query OK, 0 rows affected (0.00 sec)
- mysql> select now();
- +---------------------+
- | now() |
- +---------------------+
- | 2008-12-28 19:27:09 |
- +---------------------+
- 1 row in set (0.00 sec)
前一篇: RSS2.0元素元素列表
后一篇: HTML 中的 meta
1
The Personal Blog of Vivek Gite
How Do I Restart MySQL Server?
Each distribution comes with a shell script (read as service) to restart / stop / start MySQL server. First login as root user and open shell prompt (command prompt).
First login as root user. Now type the following command as per your Linux distro:
A) If you are using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:
* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
/etc/init.d/mysqld restart
Tip: Redhat Linux also supports service command, which can be use to start, restart, stop any service:
# service mysqld start # service mysqld stop # service mysqld restart
(B) If you are using mysql on Debian / Ubuntu Linux then use following command:
* To start mysql server:
/etc/init.d/mysql start
* To stop mysql server:
/etc/init.d/mysql stop
* To restart mysql server
/etc/init.d/mysql restart
PREVIOUS POST: Squid proxy license
NEXT POST: Exploring Linux kernel
{ 29 comments… read them below or add one }
1 sharath March 17, 2007 at 10:59 am-
2
Tim
May 28, 2007 at 4:19 am
-
3
imp
July 12, 2007 at 5:53 pm
-
4
mud
September 15, 2007 at 3:20 am
-
5
Al
May 15, 2008 at 8:47 am
-
6
vivek
May 15, 2008 at 11:04 am
-
7
Al
May 16, 2008 at 12:28 pm
-
8
Jack
May 26, 2008 at 1:24 pm
-
9
yury
August 27, 2008 at 7:33 am
-
10
Dom-2000
May 12, 2009 at 1:32 pm
-
11
Rowena
May 25, 2009 at 2:23 am
-
13
mp3
August 2, 2009 at 4:39 am
-
14
phyp
August 22, 2009 at 3:11 am
-
15
Douglas
September 14, 2009 at 2:59 pm
-
16
Muntasir
October 4, 2009 at 9:24 am
-
17
Ihsanullah
October 28, 2009 at 6:55 am
-
18
Luis
December 22, 2009 at 11:57 pm
-
19
Rosario
February 10, 2010 at 12:00 pm
-
20
NMN
March 23, 2010 at 9:49 am
-
22
Coolege
March 23, 2010 at 1:39 pm
-
23
K.Anurathan
May 19, 2010 at 6:56 am
-
24
shiva
July 7, 2010 at 7:56 am
-
25
suganthi
August 4, 2010 at 6:50 am
-
26
smapan
August 5, 2010 at 1:19 am
-
27
aaron
August 13, 2010 at 9:07 pm
-
28
casino
August 16, 2010 at 10:51 pm
-
29
munna
October 6, 2010 at 4:05 pm
-
hi
i am new to linux and i have to stop the mysqld service so as to install bugzilla … i have tried the following cmds but they have failed
/etc/init.d/mysqld stop
i am using redhat os
try the other commands –
# service mysqld start
# service mysqld stop
# service mysqld restart
These usually work for me
Thanks a lot for this! I really helped me out.
hi
iam using centos 5.0 and ihave problem with mysql
mysql cant connect
i have try to restart n all command which u show on your web but its unsuccesfull
can tell me why..?n what can i do to get mysql back like before
thanks
Hi,![:)](http://theos.in/wp-includes/images/smilies/icon_smile.gif)
I’m really embarrased to ask this, but I’m really new to linux + mysql. I installed mysql following the proceadure inhttp://dev.mysql.com/doc/refman/5.0/en/installing-binary.html, then I try to run your restart command and I get: -bash: /etc/init.d/mysql: No such file or directory.
I’m using mysql 5.0 over Debian… I’m sure I missed some configuration little detail, what can it be?
Any response is well appreciated
Al
mysqld_safe is the recommended way to start a mysqld server if you install it from source or mysql.com:
mysqld_safe &
The correct method to install it via apt-get under Debian and Ubuntu Linux. Type the following to install
apt-get install mysql-server-5.0 mysql-client-5.0
Type the following to start:
/etc/init.d/mysql start
Many thanx!![:D](http://theos.in/wp-includes/images/smilies/icon_biggrin.gif)
Hi thanks for this site, I sometimes have to restart the mysqld server myself, when it hangs. So this is really helpful, best result on google![:)](http://theos.in/wp-includes/images/smilies/icon_smile.gif)
What’s about Darwin with the ‘launchd’ installed? How do I restart mysql?
You can also use:
# kill mysqld
.. wait till it shuts down – you can check by
# ps ax | grep mysql
then start it:
# cd /usr/local/mysql/bin (or where your mysql is installed)
# ./mysqld_safe &
For fedora, You must start mysqld everytime you boot up your pc, using /etc/init.d/mysqld start
If you stop without knowing it is starting it will show errors, you must start first, ok?
12 Anonymous February 27, 2010 at 2:29 pm-
chkconfig –level 345 mysql on
will autostart mysql on fedora systems.
Thanks a lot.
Hey thanks a lot,
Very very useful post.
you use the comand top
and see all process and look,
what procces using more Memory and use killall nameprocess or kill pid process
Hi, everyone. I’ve developed a project in php which requires one shell file as backup/output, one same file – manually updated. Between these two shell files if anyone is changed, the newer should update the older one. I’ve done it already by shell script but after the update process I need to restart the service I’m working on. I know the terminal command which is “/etc/init.d/service_name restart” but when I put this in my shell file it doesn’t work. Everything else are working but not the restart command. Can anyone help me out? Thanks in advance.
Thanks, very works for me.
It saved my day. I know nothing about mysql and I hade to restart one!
I use /etc/init.d/mysqld restart in RedHat Linux and i dont had any problem
I have got a problem with MySQL. I can’t connect to the server, get the message: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
I am running Kubuntu 9.10,
I had moved my MySQL database from my stationary PC to my laptop. Everything seemed to function OK, but so I got the preceding error message both from MySQL Navigator, Knoda and trying to connect from the terminal window. Restarting the server didn’t help. Where to search for the error? I am new to MySQL.
21 Daniel T October 12, 2010 at 5:13 am-
Sounds like you only have a part of MySQL installed, you also need the client.
Try ‘sudo apt-get install mysql-client-5.1′
and then follow the steps mentioned above to start. During the install you should be prompted for setting the MySQL password etc.
you are my hero, now I know how to restart mysql… it also works the same for apache2![:)](http://theos.in/wp-includes/images/smilies/icon_smile.gif)
how to start the server with password???
when i used these commands i got it!
_________________________________________________________
administrator@administrator-desktop / $ /etc/init.d/mysql start
* Starting MySQL database server mysqld
cat: /var/run/mysqld/mysqld.pid: Permission denied
——————————————————————————————-
Is there any suitable commands?….
how to start . then system is started then my sqld , tomcat services are start give me advice
Hi everyone,
when i tried to restart mysql server i got the error as “Access denied for user@localhost” then i tried to run mysql script externally,
cd /etc/init.d/
./mysql restart
it works,.. mine is linux ubuntu 9.04 Debian based
thank you verymuch
I have somehow lost all permissions on root and don’t currently have any other users. This is troublesome because I don’t have the privileges to give myself privileges or create new users. I also don’t know how to start the mysql program with –skip-grant-tables, or I would try this. Any help would be great.
thanks all ok!
i am using fedora 13 . one problem with me is mysql is not start by using the command /etc/init.d/mysqld start if i use thid command then showing the message Command not found. Similar command is: ‘mysql’
please solve my problem……….