Nietzsche's early thinking was influenced by that of Arthur Schopenhauer, whom he first discovered in 1865.
Another important influence was Roger Joseph Boscovich, whom Nietzsche discovered and learned about through his reading, in 1866, of Friedrich Albert Lange's 1865 Geschichte des Materialismus (History of Materialism).