forget mysql root password in ubuntu

1. linux mysql的配置文件

windows下是my.ini
linux下是my.cnf

find / -name 你要找的文件(my.cnf)
mysql 的配置文件 在/etc/my.cnf 是对的

$ locate my.cnf
/etc/mysql/my.cnf

ls -l /etc/mysql/my.cnf
-rw-r–r– 1 root root 3504 Dec 7 20:01 /etc/mysql/my.cnf

修改MySQL的登录设置:
# vi /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables 
保存并且退出vi。

  • :w!  若文件属性为只读,强制写入该文件
  • :wq  保存后退出,若为:wq!,则为强制保存后退出(常用)
  • o,O   插入新的一行:从光标所在处的下一行行首开始输入字符(常用)

重新启动mysqld/mysql

sudo /etc/init.d/mysql stop
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
mysql stop/waiting

sudo service mysql restart

Start mysql client

mysql -u root

Flush privileges and reset the password

mysql> USE mysql ; 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ; 
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0

mysql> flush privileges ; 
Query OK, 0 rows affected (0.01 sec)

mysql> quit

将MySQL的登录设置修改回来 

# vi /etc/mysql/my.cnf
将刚才在[mysqld]的段中加上的skip-grant-tables删除 
保存并且退出vi。

重新启动mysqld 

# /etc/init.d/mysqld restart

sudo service mysql restart

mysql stop/waiting
mysql start/running, process 18577

改变文件权限:

chmod go-rw xxx.xxx //表示删除xxx.xxx中组群和其他人的读和写的权限

  • u 代表所有者(user)
  • g 代表所有者所在的组群(group)
  • o 代表其他人,但不是u和g (other)
  • a 代表全部的人,也就是包括u,g和o
  •  +表示添加权限, – 表示删除权限,  = 表示使之成为唯一的权限

ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘db’

via Linux平台:忘记mysql的root密码解决办法

Reset lost/forgot MYSQL root password ubuntu

2. Azure 强密码需要以下 4 项中的 3 项

  • 小写字符
  • 大写字符
  • 数字 (0-9)
  • 符号(请参阅前面提到的密码限制)

默认情况下,用户在更改其密码时需要创建强密码。 管理员能够通过 适用于 Windows Power Shell 的 Windows Azure Active Directory 模块在用户级别启用和禁用此设置。

Python 2.7.3 install numpy on ubuntu & 【sys.path】

1. Check python version:

$ python –version

Python 2.7.3

2. Go into the python interpreter:

$ python

Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

3. Check numpy installed or not

>>> import numpy

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy

4. install numpy using ‘apt-get’

$ sudo apt-get install python-numpy python-scipy

5. set the sys-path globally

>>> from pprint import pprint as pp
>>> import sys
>>> pp(sys.path)

There are two environment variables that can modify sys.pathPYTHONHOME sets an alternate value for the prefix of the Python installation. For example, if PYTHONHOME is set to /www/python, the search path will be set to ['', '/www/python/lib/pythonX.Y/', '/www/python/lib/pythonX.Y/plat-linux2', ...].
The PYTHONPATH variable can be set to a list of paths that will be added to the beginning of sys.path. For example, if PYTHONPATH is set to /www/python:/opt/py, the search path will begin with [‘/www/python’, ‘/opt/py’]. (Note that directories must exist in order to be added to sys.path; the site module removes paths that don’t exist.)

配置Path的几种方法:

1.运行时配置

运行是通过为os.path添加路径,but 关闭程序后就会失效。

import sys
sys.path.append('/home/.../mypythonfile')

2.通过环境变量配置路径

在linux下就是为 ~/.bashrc 修改 $PATH的内容,比如

export PATH=$PATH:$ORACLE_HOME/bin:/home/jim/source/python/lib/xxx

3.通过在site-packages目录添加*.pth文件配置路径
这是新版本python 2.6开始有的功能,首先确定本平台上site-packages的路径

:~$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.6/dist-packages

可以看到,在linux上,site-packages的路径是在/usr/lib/python2.6/dist-packages里
例如需要把 /home/azureuser加入path,可以这样做:

~$ sudo gedit /usr/lib/python2.6/dist-packages/a.pth

via

python 中path的配置方法

apache2 + php5 in ubuntu

 检查语法,重启web服务

谨慎起见,我们在重启服务前先检查下语法:

sudo apache2ctl configtest

sudo /etc/init.d/apache2 restart

* Restarting web server apache2
apache2: Could not reliably determine the server’s fully qualified domain name, using 10.119.170.45 for ServerName
… waiting apache2: Could not reliably determine the server’s fully qualified domain name, using 10.119.170.45 for ServerName
…done.

在 /etc/apache2/sites-enabled/000-default中,里面有这样的内容:

NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@localhost

DocumentRoot /var/www/
……

ubuntu apache2配置详解(含虚拟主机配置方法)

it’s not problem of the DNS, it’s about finding the location of Internet source files. Change the path after ‘DocumentRoot’, for example:

DocumentRoot /home/username/public_html

  •  /etc/apache2下还有一个sites-available目录,这里面才是真正的配置文件,而sites- enabled目录存放的只是一些指向这里的文件的符号链接
  • 如果apache上配置了多个虚拟主机,每个虚拟主机的配置文件都放在 sites-available下,
  • 对于虚拟主机的停用、启用就非常方便:当在sites-enabled下建立一个指向某个虚拟主机配置文件的链 接时,即启用了它;若要关闭某个虚拟主机,只需删除相应的链接即可,根本不用去改配置文件。
  • mods-available、mods-enabled 两个目录:是存放apache功能模块的配置文件和链接的。当我用apt-get install php5 安装了PHP模块后,在这两个目录里就有了 php5.load、php5.conf和指向这两个文件的链接。这种目录结果对于启用、停用某个 Apache模块是非常方便的。
  • ports.conf 设置了Apache使用的端口
  •  Virtual Hosting(虚拟主机)
    简单说就是同一台服务器可以同时处理超过一个域名(domain)

Apache2 + mod_userdir PHP as plaintext problem

Your /etc/apache2/mods-enabled/php5.conf  file should look like this:

1 <IfModule mod_php5.c>
2     <FilesMatch "\.ph(p3?|tml)$">
3         SetHandler application/x-httpd-php
4     </FilesMatch>
5     <FilesMatch "\.phps$">
6         SetHandler application/x-httpd-php-source
7         </FilesMatch>
8     # To re-enable php in user directories comment the following lines
9     # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
10     # prevents .htaccess files from disabling it.
11     #<IfModule mod_userdir.c>
12     #   <Directory /home/*/public_html>
13     #       php_admin_value engine Off
14     #   </Directory>
15     #</IfModule>
16 </IfModule>

Now just restart Apache and everything should work correctly. Type this command as root user:

1 # /etc/init.d/apache2 restart
生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web