2013年7月8日月曜日

Mysqlをインストールしてみた。

apt-get install mysql-server

apt-get install mysql-cliant

apt-get install libmysql-java

sudo mysq
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.31-0ubuntu0.13.04.1 (Ubuntu)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql>

mySQLの再起動
sudo /etc/init.d/mysql restart



※テストDBを作ってみる。

drop   database test;
create database test;
use test;
CREATE TABLE 顧客マスタ (
顧客ID  INTEGER NOT NULL,
顧客名  VARCHAR(20) NOT NULL,
連絡先  VARCHAR(20) NOT NULL,
CONSTRAINT pk_kokyaku PRIMARY KEY (顧客ID)
);

INSERT INTO 顧客マスタ (顧客ID, 顧客名, 連絡先) VALUES (1, 'aaaaaaaa', '090-0123-4001');
INSERT INTO 顧客マスタ (顧客ID, 顧客名, 連絡先) VALUES (2, 'bbbbbbbb', '090-0123-4002');
INSERT INTO 顧客マスタ (顧客ID, 顧客名, 連絡先) VALUES (3, 'cccccccc', '090-0123-4003');


select * from 顧客マスタ;

mysql>


※内蔵サンプルをみる。

 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> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)




※CentOSにもインストールしてみた。

# yum -y install mysql-server

# /etc/init.d/mysqld start
# chkconfig mysqld on
# chkconfig --list mysqld

0 件のコメント:

コメントを投稿

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...