博文

目前显示的是标签为“MySQL”的博文

dpkg: error processing mysql-server-5.5 (--configure)

rm -rf /var/lib/mysql /etc/mysql ~/.mysql apt-get –yes autoremove –purge mysql-server-5.5 apt-get –yes autoremove –purge mysql-client-5.5 apt-get –yes autoremove –purge mysql-common deluser mysql apt-get autoclean apt-get update && apt-get upgrade apt-get install mysql-server-5.5 mysql-client-5.5 NOTE: when you get ‘dpkg: error…’ please run step below: $ dpkg –configure -a Setting up mysql-server-5.5 (5.5.41-0ubuntu0.14.04.1) ... /var/lib/dpkg/info/mysql-server-5.5.postinst: line 146: logger: command not found ATTENTION: An error has occured. More info is in the syslog! /var/lib/dpkg/info/mysql-server-5.5.postinst: line 236: logger: command not found dpkg: error processing package mysql-server-5.5 (–configure): subprocess installed post-installation script returned error exit status 127 after installing bsdutils, apt-get install bsdutils mysql installation passed normally

mysql配置文件my.cnf详解

basedir = path 使用给定目录作为根目录(安装目录)。 character-sets-dir = path 给出存放着字符集的目录。 datadir = path 从给定目录读取数据库文件。 pid-file = filename 为mysqld程序指定一个存放进程ID的文件(仅适用于UNIX/Linux系统); Init-V脚本需要使用这个文件里的进程ID结束mysqld进程。 socket = filename 为MySQL客户程序与服务器之间的本地通信指定一个套接字文件(仅适用于UNIX/Linux系统; 默认设置一般是/var/lib/mysql/mysql.sock文件)。在Windows环境下,如果MySQL客户与服务器是通过命名管道进行通信 的,–sock选项给出的将是该命名管道的名字(默认设置是MySQL)。 lower_case_table_name = 1/0 新目录和数据表的名字是否只允许使用小写字母; 这个选项在Windows环境下的默认设置是1(只允许使用小写字母)。     mysqld程序:语言设置   character-sets-server = name 新数据库或数据表的默认字符集。为了与MySQL的早期版本保持兼容,这个字符集也可以用–default-character-set选项给出; 但这个选项已经显得有点过时了。 collation-server = name 新数据库或数据表的默认排序方式。 lanuage = name 用指定的语言显示出错信息。     mysqld程序:通信、网络、信息安全   enable-named-pipes 允许Windows 2000/XP环境下的客户和服务器使用命名管道(named pipe)进行通信。这个命名管道的默认名字是MySQL,但可以用–socket选项来改变。 local-infile [=0] 允许/禁止使用LOAD DATA LOCAL语句来处理本地文件。 myisam-recover [=opt1, opt2, …] 在启动时自动修复所有受损的MyISAM数据表。这个选项的可取值有4种:DEFAULT、BACKUP、QUICK和FORCE; 它们与myisamchk程序的同名选项作用相同...

mysql查看表结构命令

mysql查看表结构命令,如下:   desc 表名; show columns from 表名; describe 表名; show create table 表名;   use information_schema select * from columns where table_name=’表名’;   顺便记下: show databases; use 数据库名; show tables;       原有一unique索引AK_PAS_Name(PAC_Name)在表tb_webparamcounter中, 执行以下sql修改索引 alter table tb_webparamcounter drop index AK_PAS_Name; alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name);   若发现索引的逻辑不对,还需要再加一个字段进去,执行 alter table tb_webparamcounter drop index AK_PAS_Name; alter table tb_webparamcounter add UNIQUE AK_PAS_Name(PC_ID,PAC_Name,PAC_Value); 注意:这时的PC_ID,PAC_Name,PAC_Value三个字段不是FOREIGN KEY 否则必需先drop FOREIGN KEY,再重做上一步才行   顺便提下oracle select * from v$database; select * from all_users; select * from user_tables;  

MySQL快速清空数据表数据的SQL语句

快速清空数据库内指定表内容的SQL语句.速度也是最快的,比Delete删除方式快非常多 很简单,SQL语句如下: TRUNCATE TABLE ‘表名’ 这样就利用SQL语句清空了该数据表,而不保留日志。

Freebsd8.2 32位ports安装php5.2+fpm+mysql5.1+nginx+Zend

一、安装软件前的准备: 系统的安装:让机房最小化安装32位freebsd8.2系统。 ports的安装:机房装好系统后,远程登录,自己在线安装ports 命令: sysinstall->Configure->Distributions->ports->FTP->China->OK 修改系统密码:passwd回车 二、手动安装nginx+php (1) 进入系统后,准备cvs更新: 1. cd /usr/ports/net/cvsup-without-gui # make install clean 2. cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile 3. # ee /etc/ports-supfile 将其中的#*default host=CHANGE_THIS.FreeBSD.org一行改为: *default host=cvsup4.FreeBSDchina.org {也可以指定更新版本日期,例如加上:*default date=2009.10.05.00.00.00 (这个可以省略) } 4. 更新ports /usr/local/bin/cvsup -g -L 2 /etc/ports-supfile 2) 安装mysql #cd /usr/ports/databases/mysql51-server #make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean #cp /usr/local/share/mysql/my-large.cnf /usr/local/etc/my.cnf ##mysql的优化参数,也可以手动修改 #rehash # mysql_install_db –user=mysql ##初始化mysql #/usr/local/bin/mysqld_safe & ##启动mysql #/usr/local/bin/mysqladmin -u root password...

FreeBSD MySQL忘记密码

今天使用時出現 ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (61) 其實是忘記密碼啦XDD #背景執行mysql安全模式 mysqld_safe -u root –skip-grant-tables & #登入mysql(不用密碼) mysql -u root -p >use mysql >UPDATE user SET password=password(‘這裡輸入你的密碼’) where user=’root’; >FLUSH PRIVILEGES; >exit /usr/local/etc/rc.d/mysql-server restart

Access denied for user 'root'@'localhost' (using password: NO)

# /etc/init.d/mysql stop # mysqld_safe ——user=mysql ——skip-grant-tables  ——skip-networking & # mysql -u root mysql mysql> UPDATE user SET password=PASSWORD(’newpassword’) where USER=’root’; mysql> FLUSH PRIVILEGES; mysql> quit # /etc/init.d/mysql restart # mysql -uroot -p Enter password: <输入新设的密码newpassword> mysql>

error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

debian-sys-maint的密码是安装mysql时随时生成的 停止或重启服务都靠它 如果你修改了它的密码或覆盖掉密码,就会出现错误 error: ‘Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)’ 查看/etc/mysql/debian.cnf查看内容,可以看到有这个mysql连接用户:[client] host = localhost user = debian-sys-maint password = G1I2JcALeXXvyC50 socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] user = debian-sys-maint password = G1I2JcALeXXvyC50 socket = /var/run/mysqld/mysqld.sock basedir = /usr 直接用mysql登录,为debian-sys-maint用户改密: mysql>SET PASSWORD FOR ‘debian-sys-maint’@’localhost’ = PASSWORD(‘这里就是上面看到的密码’); mysql> flush privileges; 这样就OK了 如果删除了改用户,那只有添加了 mysql> GRANT ALL PRIVILEGES ON *.* TO ‘debian-sys-maint’@’localhost’ IDENTIFIED BY ‘这里就是上面看到的密码” WITH GRANT OPTION; mysql> flush privileges;

Optimize Apache and MySQL for a 256MB VPS

sudo nano /etc/mysql/my.cnf   Add the following line into the section [mysqld]: skip-innodb   Next locate the line skip-external-locking and add skip-locking below that line.   Now find the section labeled “Fine Tuning”. Change/add the settings in that section to match those below:   key_buffer = 16K max_allowed_packet = 1M thread_stack = 64K thread_cache_size = 4 sort_buffer = 64K net_buffer_length = 2K   Save the file (ctrl+x) and restart MySQL: sudo /etc/init.d/mysql restart If you run MySQLtuner again you will see that the “memory” warning is gone, ignore the aother warnings for the moment (you need to run the script after a few days again to get exact test results)   Optimize Apache in prefork mode If you followed the Ubuntu tutorial we’ve mentioned in the first paragraph, your Apache setup should run in prefork mode. The default settings are much to high, open the file sudo nano /etc/apache2/apache2.conf andchange the following settings:    ...

MySQL配置外网远程访问管理数据库的方法

MySQL安装后,默认只允许通过127.0.0.1的方式在服务器访问3306端口 1). 3306端口是不是没有打开? 使用nestat命令查看3306端口状态: ~# netstat -an | grep 3306 tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 从结果可以看出3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。 解决方法:修改/etc/mysql/my.cnf文件。打开文件,找到下面内容: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。 重新启动后,重新使用netstat检测:   ~# netstat -an | grep 3306 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2). 问题解决了吗? 现在使用下面命令测试: ~# mysql -h 10.1.1.2 -u root -p Enter password: ERROR 1130 (00000): Host ‘B0324-Desktop.local’ is not allowed to connect to this MySQL server 结果出乎意料,还是不行。 解决方法:原来还需要把用户权限分配各远程用户, MySQL默认root账户不带%而是127.0.0.1,因此需要修改。 登录到mysql服务器,使用grant命令分配权限 mysql> grant all on database_name.* to user_name@’%’ identified by ‘user_password’; 其中database_name、user_name和user_password根据实际情况设置。 完成后使用mysql命令连接,提示成功,为了确保正确可以再远程登陆测试一下。

每天自动备份mysql数据库并发送到Email

每天自动备份mysql数据库的脚本,并且自动发送到你指定的邮箱面,这样vpser再也不会为丢失数据烦恼啦。   mysqldump -uuser -ppassword –databases db1 db2 db3 > /home/website/backups/databackup.sql tar zcf /home/website/backups/databackup.sql.tar.gz /home/website/backups/ echo “主题:数据库备份” | mutt -a /home/website/backups/databackup.sql.tar.gz -s “内容:数据库备份” 你的邮箱 rm -r /home/website/backups/*   将上面的代码保存为automysqlbackup.sh 然后利用crontab 实现自动备份,在ssh下运行,   crontab -e   输入以下内容:   00 00 * * * /存放位置/automysqlbackup.sh   这样就实现了每天00:00自动备份mysql数据库并发送到Email 简单的说明下吧: 第一句是一次性备份多个数据库,这个要你用root权限的用户才可以的..-u后面的是数据库用户名 -p后面的是数据库密码 无需空格 db1 db2 db3为你需要备份的数据库名。 如果你的数据库用户名没有root这个权限,可以改为这样   mysqldump -uuser -ppassword db1 > /home/website/backups/db1.sql mysqldump -uuser -ppassword db2 > /home/website/backups/db1.sql mysqldump -uuser -ppassword db3 > /home/website/backups/db1.sql   第二句是将 backups 文件夹里面的数据文件压缩为文件名:databackup.sql.tar.gz 第三句是将压缩了的数据库文件发送到指定的邮箱….. 其中的主题:数据库备份,就是邮件的主题,内容:数据库备份,就是邮件的内用, /home/website...

mysql命令行下用户管理

mysql安装后好,会有一个名字为mysql的数据库,存放用户的表是user,mysql数据库的用户管理就是围绕这个表展开的,当然还有一些表,例如:tables_priv,procs_priv,clumns_priv,information_schema数据库里面的USER_PRIVILEGES等。 安装完成后,如果需要远程连接,可以这样: 1、MYSQL服务器上: 比如: C:\>mysql -uroot -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.22-rc-community-log MySQL Community Server (GPL) Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer. mysql> grant all privileges on *.* to ‘yourname’@’%’ identified by ‘youpasswd’; Query OK, 0 rows affected (0.05 sec) mysql> flush privileges; Query OK, 0 rows affected (0.06 sec) mysql> exit Bye 再把/etc/mysql/my.cnf中的bind-address=127.0.0.1注释了就可以远程连接了。 grant 权限名(sqlserver和mysql不一样的,可以看手册知道,分所有的权限用all) on 库名(*表全部).表名 to 要授权的用户名@”%”(%表示所有的IP,可以只些一个IP) identified by “密码”; 例: grant all privileges on *.* to root@”%” identified by ...

MYSQL常用命令

1.导出整个数据库 mysqldump -u 用户名 -p –default-character-set=latin1 数据库名 > 导出的文件名(数据库默认编码是latin1) mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql 2.导出一个表 mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名 mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql 3.导出一个数据库结构 mysqldump -u wcnc -p -d –add-drop-table smgp_apps_wcnc >d:wcnc_db.sql -d 没有数据 –add-drop-table 在每个create语句之前增加一个drop table 4.导入数据库 A:常用source 命令 进入mysql数据库控制台, 如mysql -u root -p mysql>use 数据库 然后使用source命令,后面参数为脚本文件(如这里用到的.sql) mysql>source wcnc_db.sql   B:使用mysqldump命令   mysqldump -u username -p dbname < filename.sql   C:使用mysql命令   mysql -u username -p -D dbname < filename.sql   一、启动与退出 1、进入MySQL:启动MySQL Command Line Client(MySQL的DOS界面),直接输入安装时的密码即可。此时的提示符是:mysql> 2、退出MySQL:quit或exit 二、库操作 1、、创建数据库 命令:create database <数据库名> 例如:建立一个名为xhkdb的数据库 mysql> create database xhkdb; 2、显示所有的数据库 命令:show databases (注意:最后有个s) mysql> show databases; 3、删除数据库 命令:drop database <数据库名...

Apache/MySQL/PHP/phpMyAdmin on FreeBSD

1. Introduction: This article describes how to setup Apache, MySQL, PHP and phpMyAdmin on a server running FreeBSD. The article was written for the software versions below but is likely to work on newer versions without too much difficulty.  2. Software: Operating System:        FreeBSD 7.0 for i386       Download Apache:                           2.2.8                                Installed from Ports Collection MySQL Server:            5.0.51a                             Installed from Ports Collection PHP & Extensions:        5.2.5                                Installed from Ports Collection p...

Freebsd9.0安装Nginx+PHP-FPM+MySQL+eAccelerator+Memcached+phpMyAdmin

图片
更新 ports 第一种方式: portsnap (自带) 首先修改/etc/portsnap.conf SERVERNAME=portsnap.cn.freebsd.org 1.下载压缩的 Ports 套件快照到 /var/db/portsnap # portsnap fetch 2.假如是首次运行 Portsnap, 则需要将快照释放到 /usr/ports: # portsnap extract 如果您已经有装好的 /usr/ports 而只想更新, 则应执行下面的命令: # portsnap update 完成后需要退出终端重新登陆。 复制cvsup更新配置文件 # cp /usr/share/examples/cvsup/ports-supfile /etc/supfile 下面是我使用的配置,屏蔽了desktop等一些服务器用不到的软件包,源已经改成中国镜像,速度比国外的主服务器要快很多 # $FreeBSD: release/9.0.0/share/examples/cvsup/ports-supfile 219858 2011-03-22 04:31:35Z glebius $ # # This file contains all of the “CVSup collections” that make up the # FreeBSD-current ports collection. # # CVSup (CVS Update Protocol) allows you to download the latest CVS # tree (or any branch of development therefrom) to your system easily # and efficiently (far more so than with sup, which CVSup is aimed # at replacing). If you’re running CVSup interactively, and are # currently using an X display server, you should run CVSup as follows # to keep your CVS tree up-to-date: # # cvsup ...