우선 내 PC에 MySQL이 저장되어있는 곳은 C:\mysql...tab키 \bin 디렉토리이다.
1. cmd 띄어 둔 후
2. >> mysql -hlocalhost -uroot -p
3 >> password: kelly2017
**문제는 가끔 원격접속 시
ERROR 2003 (HY000): Can't connect to MySQL server on '.. 해당오류가 난다.
**해결방법>> 관리자 권한 cmd 실행 후 >> mysqld.exe -u root --skip-grant-tables 명령어 or mysqld.exe -uroot --skip-networking
>>다시 관리자 원한 cmd 실행 후>> mysql hlocal -uroot -p 접속 !
<Opentutorial 참조>
데이터베이스 보기
1 | show databases; |
데이터베이스 생성
1 | CREATE DATABASE opentutorials CHARACTER SET utf8 COLLATE utf8_general_ci; |
데이터베이스 선택
1 | use opentutorials; |
테이블 생성
1 2 3 4 5 6 7 8 | CREATE TABLE `topic` ( `id` int (11) NOT NULL AUTO_INCREMENT, `title` varchar (100) NOT NULL , `description` text NOT NULL , `author` varchar (30) NOT NULL , `created` datetime NOT NULL , PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
생성된 테이블 확인
1 | show tables; |
데이터 삽입
1 2 3 4 | INSERT INTO `topic` (`id`, `title`, `description`, `author`, `created`) VALUES (1, 'About JavaScript' , '<h3>Desctiption</h3>\r\n<p>JavaScript is a dynamic computer programming language. It is most commonly used as part of web browsers, whose implementations allow client-side scripts to interact with the user, control the browser, communicate asynchronously, and alter the document content that is displayed.</p>\r\n<p>\r\nDespite some naming, syntactic, and standard library similarities, JavaScript and Java are otherwise unrelated and have very different semantics. The syntax of JavaScript is actually derived from C, while the semantics and design are influenced by the Self and Scheme programming languages.\r\n</p>\r\n<h3>See Also</h3>\r\n<ul>\r\n <li><a href="http://en.wikipedia.org/wiki/Dynamic_HTML">Dynamic HTML and Ajax (programming)</a></li>\r\n <li><a href="http://en.wikipedia.org/wiki/Web_interoperability">Web interoperability</a></li>\r\n <li><a href="http://en.wikipedia.org/wiki/Web_accessibility">Web accessibility</a></li>\r\n</ul>\r\n' , 'egoing' , '2015-03-31 12:14:00' ); INSERT INTO `topic` (`id`, `title`, `description`, `author`, `created`) VALUES (2, 'Variable and Constant' , '<h3>Desciption</h3>\r\n\r\nIn computer programming, a variable or scalar is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity or information referred to as a value. The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of the exact information it represents. The identifier in computer source code can be bound to a value during run time, and the value of the variable may thus change during the course of program execution.\r\n\r\n<h3>See Also</h3>\r\n<ul>\r\n<li>Non-local variable</li>\r\n<li>Variable interpolation</li>\r\n</ul>\r\n' , 'k8805' , '2015-05-14 10:04:00' ); INSERT INTO `topic` (`id`, `title`, `description`, `author`, `created`) VALUES (3, 'Opeartor' , '<h2>Operator</h2>\r\n<h3>Description</h3>\r\n<p>Programming languages typically support a set of operators: constructs which behave generally like functions, but which differ syntactically or semantically from usual functions</p>\r\n<p>Common simple examples include arithmetic (addition with +, comparison with >) and logical operations (such as AND or &&). </p>\r\n' , 'egoing' , '2015-06-18 05:00:00' ); INSERT INTO `topic` (`id`, `title`, `description`, `author`, `created`) VALUES ( |
이렇게 데이터를 생성한 후에 파이썬에서 접근해보려고 한다.
참고: 에러가 날때
http://oyeahhh.tistory.com/75
'Hadoop' 카테고리의 다른 글
MySql DML (0) | 2017.02.27 |
---|---|
python 데이터 - mysql 익숙해지기 (0) | 2017.01.22 |
MySQL user 생성/권한주기 -> python연동 (0) | 2017.01.22 |
JDBC (0) | 2017.01.21 |
쿼트아이1) MySQL 익숙해지기. (0) | 2017.01.21 |